luobisheng
2022-11-29 4641a877cd6a94e4d35dca7f7f14bc1443e2d2ad
src/views/operate/message/myIndex/update/index.vue
@@ -9,12 +9,13 @@
          :model="role"
          :rules="createRoleRules"
          label-position="right"
          :disabled="edit"
        >
          <!-- 提醒方式 -->
          <el-form-item class="optionItem" label="提醒方式:" prop="channelCode">
          <el-form-item class="optionItem" label="提醒方式:" prop="channelCode" >
            <el-radio-group v-model="role.channelCode">
              <el-radio label="01" value="01">站内信</el-radio>
              <el-radio label="02" value="02">邮件</el-radio>
              <el-radio label="01">站内信</el-radio>
              <el-radio label="03">邮件</el-radio>
            </el-radio-group>
            <span class="message-tip">(短信可用数: 1000条)</span>
          </el-form-item>
@@ -66,6 +67,7 @@
                    show-checkbox
                    @check="handleCheck"
                    default-expand-all
                    :default-checked-keys="checkedList"
                    node-key="id"
                  >
                  </el-tree>
@@ -83,21 +85,24 @@
                type="primary"
                @click.native.prevent="handleSubmit(0)"
                class="btn save"
                v-if="this.type=='update'||this.type=='create'"
                >保存
              </el-button>
              <el-button
                type="primary"
                @click.native.prevent="handleSubmit(1)"
                class="btn submit"
                v-if="this.type=='update'||this.type=='create'"
                >发布
              </el-button>
              <el-button
                type="primary"
                @click.native.prevent="handleView"
                class="btn submit"
                v-if="this.type=='update'||this.type=='create'"
                >预览
              </el-button>
              <el-button class="btn cancel" @click.native.prevent="handleReset"
              <el-button class="btn cancel" @click.native.prevent="handleReset" v-if="this.type=='update'||this.type=='create'"
                >重置</el-button
              >
            </div>
@@ -148,11 +153,11 @@
    };
    return {
      role: {
        messageType: "",
        messageType: null,
        head: "",
        targetTo: "",
        body: "",
        channelCode: "01",
        channelCode: null,
      },
      createRoleRules: {
        messageType: [
@@ -173,6 +178,7 @@
          },
        ],
      },
      edit: false,
      colList: [],
      departList: [],
      typeList: [],
@@ -192,11 +198,17 @@
    this.getColumnList();
    this.getDepartList();
    this.getLoginUserInfo();
    if(this.type=="view"){
      this.edit=true;
    }
    if (this.type !== "create" && this.myDataRow) {
      getMessageById(this.myDataRow.id)
          .then(res => {
            this.role = res;
            this.role.targetTo = `${this.role.targetTo.split(',').length}人`;
            if (res.targetTo) {
              this.checkedList = res.targetTo.split(',');
              this.role.targetTo = `${this.checkedList}人`;
            }
          })
          .catch(err => this.$message.error(`${err}`))
    }
@@ -205,6 +217,7 @@
    if (this.type !== 'create') {
      this.$refs.edit.editor.txt.append(this.myDataRow.body);
    }
  },
  methods: {
    // 关闭弹窗
@@ -218,7 +231,7 @@
    async getColumnList() {
      await this.$axios({
        method: "get",
        url: "sccg/message_column/getAllColumn",
        url: "sccg/message_column/getShowColumn",
      }).then((res) => {
        this.colList = res.data;
      });
@@ -231,7 +244,9 @@
        this.getColumnList();
      }
    },
    getType(){
      return this.type;
    },
    // 获取部门树
    async getDepartList() {
      await this.$axios({
@@ -265,13 +280,10 @@
    // 选中id
    handleCheck(data, node) {
      node.checkedNodes.forEach((item) => {
        if (!item.hasOwnProperty("departType")) {
          this.checkedList.push(item.id);
          this.tempNameArr.push(item.departName);
        }
      });
      this.role.targetTo = this.checkedList.length + "人";
      const checkedNodes = node.checkedNodes.filter(item => !item.children);
      this.checkedList = checkedNodes.map(item => item.id);
      this.tempNameArr = checkedNodes.map(item => item.departName);
      this.role.targetTo = this.checkedList.length ? this.checkedList.length + "人" : null;
    },
    // 新建/保存消息(1:新建,0保存消息)
@@ -289,6 +301,9 @@
            targetTo: this.checkedList.join(","),
            status: mystatus,
          };
          if (this.role.channelCode === '03') {
            delete params.messageType;
          }
          if (this.type === "create") {
            sendMessage(params)
              .then(() => {
@@ -302,7 +317,7 @@
                })
              );
          } else {
            updateMessage(params)
            updateMessage({ id: this.myDataRow.id, ...params })
              .then(() => {
                this.$emit("closeMyDialog");
                this.$message({ type: "success", message: "操作成功" });
@@ -340,6 +355,7 @@
    // 消息预览
    handleView() {
      this.role.body = this.$refs.edit.editor.txt.html();
      this.$refs.user.validate((valid) => {
        if (valid) {
          const { body, head, channelCode } = this.role;
@@ -350,7 +366,7 @@
            channelCode:
              channelCode === "01"
                ? "站内信"
                : channelCode === "02"
                : channelCode === "03"
                ? "邮件"
                : "短信",
            messageType: this.role.messageType,