index.vue 8.51 KB
<!-- 员工群发 - 列表 -->
<template>
  <div>
    <!-- class="order-detail" -->
    <d2-container>
      <!-- <div class="offline-account"> -->
      <div class="header" slot="header" style="padding: 10px 20px">
        <d2-search
          ref="showSearch"
          class="show-search"
          :search-form="searchForm"
          :label-width="labelWidth"
          :form-data="showFormData"
        />
        <div class="up-btns">
          <el-button @click="handleSearch" size="small" type="primary">
            查询
          </el-button>
          <el-button size="small" @click="handleReset"> 重置 </el-button>
        </div>
      </div>
      <!-- </d2-container>
          <d2-container> -->
      <div class="d2-container-content">
        <d2-table-header>
          <auth-button category="Button" />
        </d2-table-header>
        <d2-table
          ref="recordTable"
          :get-list-api="getListApi"
          :search-form="searchFormSearch"
          :table-params="tableParams"
          :before-search-fn="beforeSearchFn"
        >
          <div slot="auth-button" slot-scope="scope">
            <span style="margin-right: 10px">
              <auth-button :data="scope.scope" :show-btn-ids="['9130502']" />
            </span>
            <span
              style="margin-right: 10px"
              v-if="scope.scope.sendStatus == 1 || scope.scope.sendStatus == 2"
            >
              <auth-button :data="scope.scope" :show-btn-ids="['9130503']" />
            </span>
            <span style="margin-right: 10px" v-if="scope.scope.sendStatus == 3">
              <auth-button :data="scope.scope" :show-btn-ids="['9130504']" />
            </span>
            <span
              style="margin-right: 10px"
              v-if="scope.scope.sendStatus == 1 || scope.scope.sendStatus == 2"
            >
              <auth-button :data="scope.scope" :show-btn-ids="['9130505']" />
            </span>
          </div>
        </d2-table>
      </div>
    </d2-container>
    <!-- 新增提现 -->
    <!-- <add-dialog :add-visible="addVisible"
                v-if="addVisible"
                @dialogClose="addDialogClose" /> -->
  </div>
</template>

<script>
import { Util, deepClone } from "@/common/util"
import { mapActions, mapState } from "vuex"
import { contentTypeList, sendStatusList } from "@/common/constants.js"
// import { rewithdraw } from '@api/withdrawalManage'
import { contentManagerTaskPage, deleteTaskById } from "@api/contentManager"
// import addDialog from './components/addDialog'
export default {
  name: "StaffMassSendingIndex",
  components: {
    // addDialog
  },
  data() {
    return {
      userInfo: this.$store.state.d2admin.user.info,
      labelWidth: "100px",
      searchForm: {
        title: "",
        contentType: "",
        sendStatus: ""
      },
      searchFormSearch: {},
      showFormData: [
        {
          label: "标题",
          name: "title",
          type: "input",
          maxlength: "20",
          isClear: true
        },
        {
          label: "类型",
          name: "contentType",
          type: "select",
          optionList: [],
          optionId: "confId",
          optionLabel: "confValue",
          optionsName: "contentTypeList"
        },
        {
          label: "状态",
          name: "sendStatus",
          type: "select",
          optionList: [],
          optionId: "confId",
          optionLabel: "confValue",
          optionsName: "sendStatusList"
        }
      ],
      getListApi: contentManagerTaskPage,
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: "list",
        // tableOption: { width: '200px' },
        tableOption: true,
        tableColumns: [
          {
            label: "标题",
            prop: "title"
            // width: '200px'
          },
          {
            label: "类型",
            prop: "contentType",
            width: "100px",
            formatter: (cellValue) => {
              return this.baseData.contentTypeList.find(
                (item) => item.confId === cellValue.contentType
              )?.confValue
            }
          },
          {
            label: "发送时间",
            prop: "sendTime",
            width: "150px",
            formatter: (cellValue) => {
              if (cellValue.sendType == 1) {
                // 发送方式(1.即时推送,2:定时推送)
                return "立即发送"
              } else {
                return cellValue.sendTime
                  ? Util.dateFormate(cellValue.sendTime, "YYYY-MM-DD HH:mm:ss")
                  : "--"
              }
            }
          },
          {
            label: "发送员工",
            prop: "sendTotal",
            width: "100px"
          },
          {
            label: "状态",
            prop: "sendStatus",
            width: "100px",
            formatter: (cellValue) => {
              return this.baseData.sendStatusList.find(
                (item) => item.confId === cellValue.sendStatus
              )?.confValue
            }
          },
          {
            label: "创建时间",
            prop: "createdDate",
            width: "150px",
            formatter: (cellValue) => {
              return cellValue.createdDate
                ? Util.dateFormate(cellValue.createdDate, "YYYY-MM-DD HH:mm:ss")
                : "--"
            }
          }
        ]
      },
      baseData: {
        contentTypeList: deepClone(contentTypeList),
        sendStatusList: deepClone(sendStatusList)
      },

      infos: [],
      recordInfo: null,
      addVisible: false
    }
  },
  computed: {
    ...mapState({
      dowloadList: (state) => state.d2admin.user.dowloadList
    })
  },
  mounted() {
    this.getBaseData()
  },

  methods: {
    ...mapActions({
      get: "d2admin/base/get",
      close: "d2admin/page/close"
    }),
    ...mapActions("d2admin/user", ["actionSetDownloadList"]),

    async getBaseData() {
      this.getOptionsList()
    },

    beforeSearchFn() {
      return new Promise((resolve) => {
        this.searchFormSearch = deepClone(this.searchForm)
        resolve()
      })
    },

    getOptionsList() {
      this.showFormData.forEach((item, index) => {
        if (item.type === "select") {
          if (
            this.baseData[item.optionsName].length &&
            this.baseData[item.optionsName][0][
              this.showFormData[index].optionLabel
            ] !== "全部"
          ) {
            const temp = {}
            temp[this.showFormData[index].optionId] = ""
            temp[this.showFormData[index].optionLabel] = "全部"
            this.baseData[item.optionsName].unshift(temp)
          }
          this.$set(
            this.showFormData[index],
            "optionList",
            this.baseData[item.optionsName]
          )
        }
      })
    },

    handleSearch() {
      this.$refs.recordTable.refreshTable(false, true)
    },
    handleReset() {
      this.searchForm = {
        title: "",
        contentType: "",
        sendStatus: ""
      }
      this.$refs.recordTable.refreshTable(false, true)
    },

    handleAdd(scope) {
      console.log(scope)
      // this.addVisible = !this.addVisible
      if (scope) {
        this.$router.push({
          name: "SopContentAdd",
          query: {
            id: scope.id
          }
        })
      } else {
        this.$router.push({ name: "SopContentAdd" })
      }
    },
    handleDetail(row) {
      this.$router.push({
        name: "sopContentDetail",
        query: {
          id: row.id
        }
      })
    },

    addDialogClose(obj) {
      this[obj.attrName] = !this[obj.attrName]
      if (obj.flag) {
        this.$refs.recordTable.refreshTable()
      }
    },

    // 删除
    handleDel(row) {
      this.$confirm("删除后不可恢复,是否确定删除?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        closeOnClickModal: false
      })
        .then(() => {
          deleteTaskById({ id: row.id }).then((res) => {
            this.notice.okTips()
            this.$refs.recordTable.refreshTable()
          })
        })
        .catch((err) => {
          console.log(err)
        })
    },

    goStatisticsPage(row) {
      this.$router.push({
        name: "statisticsPage",
        query: {
          id: row.id,
          title: row.title
        }
      })
    }
  }
}
</script>
<style scoped>
.count-txt {
  font-weight: 700;
  color: #2a58ad;
  margin: 0 2px;
}

.leftSpan {
  display: inline-block;
  box-sizing: border-box;
  margin-right: 10px;
}
</style>