Browse Source

修改bug

695593266@qq.com 6 months ago
parent
commit
adfb4adcfd

+ 174 - 166
src/views/enterpriseModel/dept/components/staffSelection.vue

@@ -136,153 +136,188 @@
   </div>
 </template>
 <script>
-import { listOrganizations, getUserPage } from '@/api/system/organization';
-export default {
-  data() {
-    return {
-      form: {
-        groupId: null
+  import { listOrganizations, getUserPage } from '@/api/system/organization';
+  export default {
+    data() {
+      return {
+        form: {
+          groupId: null
+        },
+        treeList: [],
+        staffList: [],
+        selectStafflist: [], //已选员工
+        defaultProps: {
+          children: 'children',
+          label: 'name',
+          value: 'code'
+        },
+        pageNum: 1, //设备当前页数
+        size: 10,
+        isMore: false,
+        dialogVisible: false
+      };
+    },
+    created() {},
+    methods: {
+      open(selectedList) {
+        this.dialogVisible = true;
+        // this.selectStafflist = selectedList;
+        this.selectStafflist = selectedList.map((item) => {
+          item.name = item.name ? item.name : item.recipientName;
+          item.id = item.id ? item.id : item.recipientId;
+
+          return item;
+        });
+
+        console.log(this.selectStafflist, 'this.selectStafflist');
+        this.getInfo();
       },
-      treeList: [],
-      staffList: [],
-      selectStafflist: [], //已选员工
-      defaultProps: {
-        children: 'children',
-        label: 'name',
-        value: 'code'
+      //初始数据
+      async getInfo() {
+        let list = await listOrganizations();
+        this.treeList = this.$util.toTreeData({
+          data: list,
+          idField: 'id',
+          parentIdField: 'parentId'
+        });
+        //this.treeList = res.data;
       },
-      pageNum: 1, //设备当前页数
-      size: 10,
-      isMore: false,
-      dialogVisible: false
-    };
-  },
-  created() {},
-  methods: {
-    open(selectedList) {
-      this.dialogVisible = true;
-      this.selectStafflist = selectedList;
-      this.getInfo();
-    },
-    //初始数据
-    async getInfo() {
-      let list = await listOrganizations();
-      this.treeList = this.$util.toTreeData({
-        data: list,
-        idField: 'id',
-        parentIdField: 'parentId'
-      });
-      //this.treeList = res.data;
-    },
-    //选择分类
-    handleNodeClick(data) {
-      this.staffList = [];
+      //选择分类
+      handleNodeClick(data) {
+        this.staffList = [];
 
-      this.form.groupId = data.id;
-      let params = {
-        pageNum: 1,
-        size: this.size,
-        groupId: this.form.groupId
-      };
-      this.getStaffList(params);
-    },
-    //获取员工列表
-    async getStaffList(params) {
-      let res = await getUserPage(params);
-      let list = res.list;
-      if (list.length < res.count) {
-        this.isMore = true;
-      } else {
-        this.isMore = false;
-      }
-      list.forEach((el) => {
-        let _index = this.selectStafflist.findIndex((n) => n.id == el.id);
-        if (_index !== -1) {
-          el.disabled = true;
+        this.form.groupId = data.id;
+        let params = {
+          pageNum: 1,
+          size: this.size,
+          groupId: this.form.groupId
+        };
+        this.getStaffList(params);
+      },
+      //获取员工列表
+      async getStaffList(params) {
+        let res = await getUserPage(params);
+        let list = res.list;
+        if (list.length < res.count) {
+          this.isMore = true;
         } else {
-          el.disabled = false;
-        }
-      });
-      this.staffList = [...this.staffList, ...list];
-      // this.pageNum = res.pageNum;
-    },
-    //查询更多员工
-    async getMore() {
-      this.pageNum = this.pageNum + 1;
-      let params = {
-        pageNum: this.pageNum,
-        size: this.size,
-        groupId: this.form.groupId
-      };
-      this.getStaffList(params);
-    },
-    //选择员工
-    choiceAsset(info) {
-      let data = JSON.parse(JSON.stringify(info));
-      this.selectStafflist.push(data);
-      info.disabled = true;
-    },
-    //删除已选员工
-    deleteSelectStaff(info, index) {
-      this.staffList.forEach((el) => {
-        if (el.id == info.id) {
-          el.disabled = false;
+          this.isMore = false;
         }
-      });
-      this.selectStafflist.splice(index, 1);
-    },
-    //保存
-    sumbit() {
-      this.selectStafflist = this.selectStafflist || [];
-      this.$emit('confirm', JSON.parse(JSON.stringify(this.selectStafflist)));
-      this.handleClose();
-    },
-    handleClose() {
-      this.staffList = [];
-      this.selectStafflist = [];
-      this.dialogVisible = false;
+        list.forEach((el) => {
+          let _index = this.selectStafflist.findIndex((n) => n.id == el.id);
+          if (_index !== -1) {
+            el.disabled = true;
+          } else {
+            el.disabled = false;
+          }
+        });
+        this.staffList = [...this.staffList, ...list];
+        // this.pageNum = res.pageNum;
+      },
+      //查询更多员工
+      async getMore() {
+        this.pageNum = this.pageNum + 1;
+        let params = {
+          pageNum: this.pageNum,
+          size: this.size,
+          groupId: this.form.groupId
+        };
+        this.getStaffList(params);
+      },
+      //选择员工
+      choiceAsset(info) {
+        let data = JSON.parse(JSON.stringify(info));
+        this.selectStafflist.push(data);
+        info.disabled = true;
+      },
+      //删除已选员工
+      deleteSelectStaff(info, index) {
+        this.staffList.forEach((el) => {
+          if (el.id == info.id) {
+            el.disabled = false;
+          }
+        });
+        this.selectStafflist.splice(index, 1);
+      },
+      //保存
+      sumbit() {
+        this.selectStafflist = this.selectStafflist || [];
+        this.$emit('confirm', JSON.parse(JSON.stringify(this.selectStafflist)));
+        this.handleClose();
+      },
+      handleClose() {
+        this.staffList = [];
+        this.selectStafflist = [];
+        this.dialogVisible = false;
+      }
     }
-  }
-};
+  };
 </script>
 
 <style lang="scss" scoped>
-.container {
-  padding: 10px 0;
-}
-.zw-container {
-  height: 500px;
-  overflow-y: auto;
-}
-.zw-header-title {
-  display: inline-block;
-  margin-right: 10px;
-  font-weight: 600;
-}
-.details-title {
-  line-height: 32px;
-  height: 32px;
-}
-.zw-page-list-p {
-  font-size: 14px;
-  margin-bottom: 18px;
-  display: flex;
-  justify-content: space-between;
-  // align-items: center;
-  .zw-page-list-right {
-    display: flex;
+  .container {
+    padding: 10px 0;
+  }
+  .zw-container {
+    height: 500px;
+    overflow-y: auto;
+  }
+  .zw-header-title {
+    display: inline-block;
+    margin-right: 10px;
+    font-weight: 600;
   }
-}
-.zw-page {
-  background: #fff;
-  //padding: 20px 0;
-  height: 600px;
-  .zw-page-left {
-    padding: 0 10px;
+  .details-title {
+    line-height: 32px;
+    height: 32px;
+  }
+  .zw-page-list-p {
+    font-size: 14px;
+    margin-bottom: 18px;
+    display: flex;
+    justify-content: space-between;
+    // align-items: center;
+    .zw-page-list-right {
+      display: flex;
+    }
   }
-  .zw-page-main {
-    padding: 0 10px;
-    .zw-page-main-list {
+  .zw-page {
+    background: #fff;
+    //padding: 20px 0;
+    height: 600px;
+    .zw-page-left {
+      padding: 0 10px;
+    }
+    .zw-page-main {
+      padding: 0 10px;
+      .zw-page-main-list {
+        span {
+          margin-right: 10px;
+        }
+        .zw-page-span-num {
+          font-size: 12px;
+          color: #157a2c;
+        }
+        .zw-page-p-operation {
+          text-align: right;
+          // width: 200px;
+        }
+        .zw-page-operation-num {
+          width: 100px;
+          margin: 0 10px;
+        }
+      }
+      .zw-page-list-more {
+        text-align: center;
+      }
+    }
+    .zw-page-right {
+      .zw-card-header {
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        height: 32px;
+      }
       span {
         margin-right: 10px;
       }
@@ -290,37 +325,10 @@ export default {
         font-size: 12px;
         color: #157a2c;
       }
-      .zw-page-p-operation {
-        text-align: right;
-        // width: 200px;
-      }
-      .zw-page-operation-num {
-        width: 100px;
-        margin: 0 10px;
-      }
-    }
-    .zw-page-list-more {
-      text-align: center;
     }
   }
-  .zw-page-right {
-    .zw-card-header {
-      display: flex;
-      justify-content: space-between;
-      align-items: center;
-      height: 32px;
-    }
-    span {
-      margin-right: 10px;
-    }
-    .zw-page-span-num {
-      font-size: 12px;
-      color: #157a2c;
-    }
+  .notes {
+    font-size: 12px;
+    color: #909090;
   }
-}
-.notes {
-  font-size: 12px;
-  color: #909090;
-}
 </style>

+ 141 - 117
src/views/notifyManage/templateManage/components/addOrEditDialog.vue

@@ -12,7 +12,7 @@
       <el-form-item label="模板编码:" prop="code">
         <el-input
           clearable
-          :disabled="dialogType=='view'"
+          :disabled="dialogType == 'view'"
           v-model="formData.code"
           placeholder="请输入"
         />
@@ -20,7 +20,7 @@
       <el-form-item label="模板名称:" prop="name">
         <el-input
           clearable
-          :disabled="dialogType=='view'"
+          :disabled="dialogType == 'view'"
           v-model="formData.name"
           placeholder="请输入"
         />
@@ -28,14 +28,14 @@
       <el-form-item label="默认发送人:" prop="nickname">
         <el-input
           clearable
-          :disabled="dialogType=='view'"
+          :disabled="dialogType == 'view'"
           v-model.number="formData.nickname"
           placeholder="请输入排序"
         />
       </el-form-item>
       <el-form-item label="接收人类型:" prop="recipientType">
         <el-select
-          :disabled="dialogType=='view'"
+          :disabled="dialogType == 'view'"
           v-model="formData.recipientType"
           placeholder="请选择接收人类型"
           @change="handleRecipientTypeChange"
@@ -48,12 +48,19 @@
           />
         </el-select>
       </el-form-item>
-      <el-form-item v-if="formData.recipientType != 0" label="接收人:" prop="recipient">
-        <role-select v-if="formData.recipientType == 2" v-model="formData.recipient" />
+      <el-form-item
+        v-if="formData.recipientType != 0"
+        label="接收人:"
+        prop="recipient"
+      >
+        <role-select
+          v-if="formData.recipientType == 2"
+          v-model="formData.recipient"
+        />
         <el-input
           v-if="formData.recipientType == 1"
           clearable
-          :disabled="dialogType=='view'"
+          :disabled="dialogType == 'view'"
           v-model="formData.recipientName"
           placeholder="请选择"
           @click.native="handleRecipientClick"
@@ -63,30 +70,40 @@
         <el-input
           clearable
           type="textarea"
-          :disabled="dialogType=='view'"
+          :disabled="dialogType == 'view'"
           v-model="formData.content"
           placeholder="请输入"
         />
       </el-form-item>
       <el-form-item label="状态:" prop="status">
-        <el-radio :disabled="dialogType=='view'" v-model="formData.status" :label="1">启用</el-radio>
-        <el-radio :disabled="dialogType=='view'" v-model="formData.status" :label="0">禁用</el-radio>
+        <el-radio
+          :disabled="dialogType == 'view'"
+          v-model="formData.status"
+          :label="1"
+          >启用</el-radio
+        >
+        <el-radio
+          :disabled="dialogType == 'view'"
+          v-model="formData.status"
+          :label="0"
+          >禁用</el-radio
+        >
       </el-form-item>
 
       <el-form-item label="备注:" prop="remark">
         <el-input
           clearable
           type="textarea"
-          :disabled="dialogType=='view'"
+          :disabled="dialogType == 'view'"
           v-model="formData.remark"
           placeholder="请输入"
         />
       </el-form-item>
-
-
     </el-form>
     <template v-slot:footer>
-      <el-button type="primary" :loading="loading" @click="save">确认</el-button>
+      <el-button type="primary" :loading="loading" @click="save"
+        >确认</el-button
+      >
       <el-button @click="closeDialog">返回</el-button>
     </template>
     <staffSelection
@@ -97,61 +114,62 @@
 </template>
 
 <script>
-import dictMixins from '@/mixins/dictMixins';
-import {notifyTemplateGetByIdAPI, notifyTemplateSaveAPI, notifyTemplateUpdateAPI} from "@/api/notifyManage";
-import RoleSelect from '@/views/system/user/components/role-select.vue';
-import staffSelection from '@/views/enterpriseModel/dept/components/staffSelection.vue';
-export default {
-  name: 'addOrEditDialog',
-  props: {
-    addOrEditDialogFlag: [Boolean],
-  },
-  components: {
-    RoleSelect,
-    staffSelection
-  },
-  mixins: [dictMixins],
-  data() {
-
-    return {
-      recipientTypeOptions: [
-        {
-          value: 0,
-          label: '业务自定义'
-        },
-        {
-          value: 1,
-          label: '指定人'
-        },
-        {
-          value: 2,
-          label: '指定角色'
+  import dictMixins from '@/mixins/dictMixins';
+  import {
+    notifyTemplateGetByIdAPI,
+    notifyTemplateSaveAPI,
+    notifyTemplateUpdateAPI
+  } from '@/api/notifyManage';
+  import RoleSelect from '@/views/system/user/components/role-select.vue';
+  import staffSelection from '@/views/enterpriseModel/dept/components/staffSelection.vue';
+  export default {
+    name: 'addOrEditDialog',
+    props: {
+      addOrEditDialogFlag: [Boolean]
+    },
+    components: {
+      RoleSelect,
+      staffSelection
+    },
+    mixins: [dictMixins],
+    data() {
+      return {
+        recipientTypeOptions: [
+          {
+            value: 0,
+            label: '业务自定义'
+          },
+          {
+            value: 1,
+            label: '指定人'
+          },
+          {
+            value: 2,
+            label: '指定角色'
+          }
+        ],
+        users: [],
+        // 表单数据
+        formData: {
+          code: '',
+          name: '',
+          nickname: '',
+          content: '',
+          status: 1,
+          remark: '',
+          recipientType: 0,
+          recipient: [],
+          recipientName: ''
         },
-      ],
-      users: [],
-      // 表单数据
-      formData: {
-        code: '',
-        name: '',
-        nickname: '',
-        content: '',
-        status: 1,
-        remark: '',
-        recipientType: 0,
-        recipient: [],
-        recipientName: ''
-      },
-      title: null,
-
+        title: null,
 
-      
-      dialogType: '',
-      // 提交状态
-      loading: false,
-    };
-  },
-  computed: {
-    // 表单验证规则
+        dialogType: '',
+        // 提交状态
+        loading: false
+      };
+    },
+    computed: {
+      // 表单验证规则
       rules() {
         return {
           name: [
@@ -202,68 +220,74 @@ export default {
               message: '请选择接收人',
               trigger: 'change'
             }
-          ],
-        }
+          ]
+        };
       }
-  },
-  created() {
-  },
-  methods: {
-    handleRecipientTypeChange() {
-      this.formData.recipient = [];
-      this.formData.recipientName = '';
     },
-    handleRecipientClick() {
-      this.$refs.staffSelection.open(
+    created() {},
+    methods: {
+      handleRecipientTypeChange() {
+        this.formData.recipient = [];
+        this.formData.recipientName = '';
+      },
+      handleRecipientClick() {
+        console.log(this.formData.recipient, 'this.formData.recipient');
+        this.$refs.staffSelection.open(
           JSON.parse(JSON.stringify(this.formData.recipient))
         );
-    },
-    
-    confirmStaffSelection(data) {
-      console.log(data);
-        this.formData.recipient = data.map(item => {
+      },
+
+      confirmStaffSelection(data) {
+        console.log(data);
+        this.formData.recipient = data.map((item) => {
           return {
             ...item,
             recipientId: item.id,
             recipientName: item.name,
             type: this.formData.recipientType
-          }
+          };
         });
-        this.formData.recipientName = data.map(item => item.name).join(',');
+        this.formData.recipientName = data.map((item) => item.name).join(',');
       },
-    init(type, row = {}) {
-      this.title = type == 'add' ? '新增' : '修改'
-      this.dialogType = type
-      if (type !== 'add') {
-        this.getNotifyTemplateInfo(row)
-      }
-    },
-    async getNotifyTemplateInfo(row) {
-      this.formData = await notifyTemplateGetByIdAPI(row.id)
-    },
-    /* 保存编辑 */
-    save() {
-      this.$refs.formRef.validate(async (valid) => {
-        if (!valid) return this.$message.warning('有必填项未填写,请检查');
-        this.loading = true;
-
-        const params = {...this.formData};
-        const API = this.dialogType == 'add' ? notifyTemplateSaveAPI : notifyTemplateUpdateAPI
-        try {
-          await API(params)
-          this.$message.success('操作成功')
-          this.$emit('done')
-          this.closeDialog()
-        } catch (e) {
-          this.loading = false;
+      init(type, row = {}) {
+        this.title = type == 'add' ? '新增' : '修改';
+        this.dialogType = type;
+        if (type !== 'add') {
+          this.getNotifyTemplateInfo(row);
         }
+      },
+      async getNotifyTemplateInfo(row) {
+        this.formData = await notifyTemplateGetByIdAPI(row.id);
 
-      });
-    },
-    /* 关闭弹窗 */
-    closeDialog() {
-      this.$emit('update:addOrEditDialogFlag', false)
+        this.formData.recipientName = this.formData.recipient
+          .map((item) => item.recipientName)
+          .join(',');
+      },
+      /* 保存编辑 */
+      save() {
+        this.$refs.formRef.validate(async (valid) => {
+          if (!valid) return this.$message.warning('有必填项未填写,请检查');
+          this.loading = true;
+
+          const params = { ...this.formData };
+          const API =
+            this.dialogType == 'add'
+              ? notifyTemplateSaveAPI
+              : notifyTemplateUpdateAPI;
+          try {
+            await API(params);
+            this.$message.success('操作成功');
+            this.$emit('done');
+            this.closeDialog();
+          } catch (e) {
+            this.loading = false;
+          }
+        });
+      },
+      /* 关闭弹窗 */
+      closeDialog() {
+        this.$emit('update:addOrEditDialogFlag', false);
+      }
     }
-  },
-};
+  };
 </script>

+ 26 - 0
src/views/notifyManage/templateManage/index.vue

@@ -21,6 +21,18 @@
             新建
           </el-button>
         </template>
+
+        <template v-slot:recipientType="{ row }">
+          <el-tag size="mini" v-if="row.recipientType == 0">业务自定义</el-tag>
+          <el-tag size="mini" v-if="row.recipientType == 1">指定人</el-tag>
+          <el-tag size="mini" v-if="row.recipientType == 2">指定角色</el-tag>
+        </template>
+
+        <template v-slot:recipient="{ row }">
+          <span v-for="it of row.recipient">
+            <el-tag size="mini">{{ it.recipientName }}</el-tag>
+          </span>
+        </template>
         <!-- 操作列 -->
         <template v-slot:action="{ row }">
           <el-link
@@ -107,6 +119,20 @@
             width: '100',
             align: 'center'
           },
+          {
+            prop: 'recipientType',
+            slot: 'recipientType',
+            label: '接收人类型',
+            width: '100',
+            align: 'center'
+          },
+          {
+            prop: 'recipient',
+            slot: 'recipient',
+            label: '接收人',
+            width: '120',
+            align: 'center'
+          },
           {
             prop: 'status',
             label: '状态',