소스 검색

工种管理功能优化:重构资质对话框为工种选择并完善用户工种关联功能

yusheng 9 달 전
부모
커밋
05362bbb65

+ 30 - 30
src/views/factoryModel/jobManagement/components/aptitudeDialog.vue

@@ -6,7 +6,7 @@
       append-to-body
       :close-on-click-modal="false"
       custom-class="ele-dialog-form"
-      title="资质列表"
+      title="选择工种"
       @update:visible="updateVisible"
       :maxable="true"
     >
@@ -15,12 +15,9 @@
           ref="table"
           :initLoad="false"
           :columns="columns"
-          :current.sync="current"
-          highlight-current-row
+          :selection.sync="selection"
           :datasource="datasource"
           tool-class="ele-toolbar-form"
-          cache-key="systemOrgUserTable"
-          @selection-change="handleSelectionChange"
         >
         </ele-pro-table>
       </div>
@@ -34,12 +31,19 @@
 
 <script>
   import dictMixins from '@/mixins/dictMixins';
-  import { getProfessionCertificationPageList } from '@/api/factoryModel';
+  import { getProfessionPageList } from '@/api/factoryModel';
   export default {
     mixins: [dictMixins],
+    props: {
+      disabledIds: {
+        default: () => {
+          return [];
+        }
+      }
+    },
     data() {
       return {
-        multipleSelection: [],
+        selection: [],
         visible: false,
         levelOptions: [
           {
@@ -63,7 +67,10 @@
             type: 'selection',
             width: 45,
             align: 'center',
-            fixed: 'left'
+            fixed: 'left',
+            selectable:(row)=>{
+              return !this.disabledIds.includes(row.id);
+            }
           },
           {
             label: '序号',
@@ -106,29 +113,21 @@
             formatter: (_row) => {
               return this.levelOptions.filter(
                 (item) => _row.level == item.value
-              )[0].label;
+              )[0]?.label;
             }
           },
           {
-            slot: 'startTime',
-            prop: 'startTime',
-            label: '有效开始时间',
-            showOverflowTooltip: true,
-            align: 'center',
-            minWidth: 110
-          },
-          {
-            slot: 'endTime',
-            prop: 'endTime',
-            label: '有效结束时间',
+            slot: 'hourCost',
+            prop: 'hourCost',
+            label: '标准工时费',
             showOverflowTooltip: true,
             align: 'center',
             minWidth: 110
           },
           {
-            slot: 'accessory.name',
-            prop: 'accessory.name',
-            label: '附件',
+            slot: 'unit',
+            prop: 'unit',
+            label: '工时费单位',
             showOverflowTooltip: true,
             align: 'center',
             minWidth: 110
@@ -136,24 +135,25 @@
         ]
       };
     },
+    created() {
+      this.requestDict('工种类型');
+    },
     methods: {
       updateVisible(value) {
         this.visible = value;
         this.$emit('update:visible', value);
       },
-      handleSelectionChange(val) {
-        this.multipleSelection = val;
-      },
+
       async handleMine() {
-        if (this.multipleSelection?.length <= 0) {
-          this.$message.warning('请至少选择一个资质!');
+        if (this.selection?.length <= 0) {
+          this.$message.warning('请至少选择一条数据!');
           return;
         }
-        this.$emit('success', this.multipleSelection);
+        this.$emit('success', this.selection);
         this.updateVisible(false);
       },
       async datasource({ page, limit, where, order }) {
-        const res = await getProfessionCertificationPageList({
+        const res = await getProfessionPageList({
           ...where,
           ...order,
           pageNum: page,

+ 164 - 163
src/views/factoryModel/station/index.vue

@@ -38,7 +38,6 @@
           </div>
         </template>
 
-
         <template v-slot:enabled="{ row }">
           {{ dict.enabled[row.enabled] }}
         </template>
@@ -77,181 +76,183 @@
         </template>
       </ele-pro-table>
     </el-card>
-    <edit
-      ref="edit"
-      @done="done"
-
-    ></edit>
+    <edit ref="edit" @done="done"></edit>
   </div>
 </template>
 <script>
-import tabMixins from '@/mixins/tableColumnsMixin';
-import search from './components/search.vue';
-import edit from './components/edit.vue';
-import {
-  deleteFactoryworkstation,
-  getFactoryworkstation,
-  getFactoryarea
-} from '@/api/factoryModel';
-import { listOrganizations } from '@/api/system/organization';
-export default {
-  mixins: [tabMixins],
-  components: {
-    search,
-    edit
-  },
-    data () {
-    return {
-      columns: [
-        {
-          width: 45,
-          type: 'index',
-          columnKey: 'index',
-          align: 'center'
-        },
-        {
-          prop: 'code',
-          label: '工位编码'
-        },
-        {
-          label: '工位名称',
-          prop: 'name'
-        },
-        {
-          label: '责任人',
-          prop: 'leaderName',
-          slot: 'factory'
-        },
-        {
-          label: '所属区域',
-            prop: 'areaName',
-        },
-
-        {
-          label: '所属工厂',
-            prop: 'factoryName',
-
-        },
+  import tabMixins from '@/mixins/tableColumnsMixin';
+  import search from './components/search.vue';
+  import edit from './components/edit.vue';
+  import {
+    deleteFactoryworkstation,
+    getFactoryworkstation,
+    getFactoryarea
+  } from '@/api/factoryModel';
+  import { listOrganizations } from '@/api/system/organization';
+  export default {
+    mixins: [tabMixins],
+    components: {
+      search,
+      edit
+    },
+    data() {
+      return {
+        columns: [
+          {
+            width: 45,
+            type: 'index',
+            columnKey: 'index',
+            align: 'center'
+          },
+          {
+            prop: 'code',
+            label: '工位编码'
+          },
+          {
+            label: '工位名称',
+            prop: 'name'
+          },
+          {
+            label: '责任人',
+            prop: 'leaderName',
+            slot: 'factory'
+          },
+          {
+            label: '所属区域',
+            prop: 'areaName'
+          },
 
-        {
-          label: '所属厂房',
-            prop: 'workshopPlanName',
+          {
+            label: '所属工厂',
+            prop: 'factoryName'
+          },
 
-        },
-        {
-          label: '所属车间',
-          prop: 'workshopName'
-        },
-        {
-          label: '所属产线',
-          prop: 'productionLineName'
-        },
-        {
-          label: '节拍时间',
-          prop: 'extInfo.meterTime',
-          slot: 'meterTime'
-        },
-        {//修改此prop名称时,请同步修改columnKey属性和下方selectType方法
-          label: '状态',
-          prop: 'enabled',
-          slot: 'enabled',
-          filters: [
+          {
+            label: '所属厂房',
+            prop: 'workshopPlanName'
+          },
+          {
+            label: '所属车间',
+            prop: 'workshopName'
+          },
+          {
+            label: '所属产线',
+            prop: 'productionLineName'
+          },
+          {
+            label: '设备名称',
+            prop: 'extInfo.assetName',
+            formatter: (_row, _column, cellValue) => {
+              return typeof cellValue === 'string' ? cellValue :'';
+            }
+          },
+          {
+            label: '节拍时间',
+            prop: 'extInfo.meterTime',
+            slot: 'meterTime'
+          },
+          {
+            //修改此prop名称时,请同步修改columnKey属性和下方selectType方法
+            label: '状态',
+            prop: 'enabled',
+            slot: 'enabled',
+            filters: [
               { value: 1, text: '生效' },
-              { value: 0, text: '未生效' },
+              { value: 0, text: '未生效' }
             ],
-          filterMultiple: false,
-          columnKey: 'enabled'
+            filterMultiple: false,
+            columnKey: 'enabled'
+          },
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 220,
+            align: 'center',
+            resizable: false,
+            slot: 'action',
+            showOverflowTooltip: true
+          }
+        ],
+        dict: {
+          groupId: [],
+          factory: [],
+          enabled: {
+            1: '生效',
+            0: '未生效'
+          }
         },
-        {
-          columnKey: 'action',
-          label: '操作',
-          width: 220,
-          align: 'center',
-          resizable: false,
-          slot: 'action',
-          showOverflowTooltip: true
-        }
-      ],
-      dict: {
-        groupId: [],
-        factory: [],
-        enabled: {
-          1: '生效',
-          0: '未生效'
-        }
-      },
-      pageSize: this.$store.state.tablePageSize,
-      cacheKeyUrl: 'ef00833a-factoryModel-station'
-    };
-  },
-    created () {
-    this.getGs();
-    this.getFactoryarea();
-  },
-  methods: {
+        pageSize: this.$store.state.tablePageSize,
+        cacheKeyUrl: 'ef00833a-factoryModel-station'
+      };
+    },
+    created() {
+      this.getGs();
+      this.getFactoryarea();
+    },
+    methods: {
       selectType(value) {
-        let where = {}
+        let where = {};
         if (value.enabled.length > 0) {
-          where['enable'] = value.enabled[0]
+          where['enable'] = value.enabled[0];
         }
-        this.search(where)
+        this.search(where);
+      },
+      datasource({ page, where, limit }) {
+        return getFactoryworkstation({
+          ...where,
+          pageNum: page,
+          size: limit
+        });
+      },
+      search(where) {
+        this.$refs.table.reload({
+          where: where,
+          page: 1
+        });
+      },
+      openEdit(type, row) {
+        this.$refs.edit.open(type, row);
       },
-      datasource ({ page, where, limit }) {
-      return getFactoryworkstation({
-        ...where,
-        pageNum: page,
-        size: limit
-      });
-    },
-      search (where) {
-      this.$refs.table.reload({
-        where: where,
-        page: 1
-      });
-    },
-      openEdit (type, row) {
-      this.$refs.edit.open(type, row);
-    },
 
-    // 获取公司数据
-      getGs () {
-      listOrganizations().then((list) => {
-        this.dict.groupId = JSON.parse(JSON.stringify(list));
-      });
-    },
-    // 回显车间
-      showWorkshop (row) {
-      let result = row.parent.find((n) => n.id == row.parentId);
-      if (result) {
-        return result.name;
-      } else {
-        return '';
-      }
-    },
-    // 获取工厂数据
-      getFactoryarea () {
-      let par = {
-        type: 1,
-        size: 9999,
-          type: 2,
-      };
-      getFactoryarea(par).then((res) => {
-        this.dict.factory = res.list;
-      });
-    },
-      remove (row) {
-      deleteFactoryworkstation(row.id)
-        .then((message) => {
-          this.$message.success(message);
-          this.done();
-        })
-        .catch((e) => {
-          this.$message.error(e.message);
+      // 获取公司数据
+      getGs() {
+        listOrganizations().then((list) => {
+          this.dict.groupId = JSON.parse(JSON.stringify(list));
         });
-    },
-      done () {
-      this.$refs.search.search();
+      },
+      // 回显车间
+      showWorkshop(row) {
+        let result = row.parent.find((n) => n.id == row.parentId);
+        if (result) {
+          return result.name;
+        } else {
+          return '';
+        }
+      },
+      // 获取工厂数据
+      getFactoryarea() {
+        let par = {
+          type: 1,
+          size: 9999,
+          type: 2
+        };
+        getFactoryarea(par).then((res) => {
+          this.dict.factory = res.list;
+        });
+      },
+      remove(row) {
+        deleteFactoryworkstation(row.id)
+          .then((message) => {
+            this.$message.success(message);
+            this.done();
+          })
+          .catch((e) => {
+            this.$message.error(e.message);
+          });
+      },
+      done() {
+        this.$refs.search.search();
+      }
     }
-  }
-};
+  };
 </script>

+ 156 - 8
src/views/system/organization/components/org-user-edit.vue

@@ -102,6 +102,7 @@
               clearable
               filterable
               v-model="form.postId"
+              multiple
             >
             </DictSelection>
           </el-form-item>
@@ -1058,6 +1059,33 @@
             </template>
           </ele-pro-table>
         </el-tab-pane>
+        <el-tab-pane label="工种" name="jobManagement">
+          <ele-pro-table
+            ref="table"
+            :columns="jobColumns"
+            :datasource="form.professions"
+            max-height="350px"
+            :toolkit="[]"
+            class="el-form-box"
+            :need-page="false"
+          >
+            <!-- 表头工具栏 -->
+            <template v-slot:toolbar>
+              <el-button type="primary" @click="$refs.aptitudeDialogRef.open()"
+                >添加</el-button
+              >
+            </template>
+            <template v-slot:action="{ row, $index }">
+              <el-link
+                type="danger"
+                :underline="false"
+                icon="el-icon-delete"
+                @click="deleteJob($index)"
+                >删除
+              </el-link>
+            </template>
+          </ele-pro-table>
+        </el-tab-pane>
       </el-tabs>
     </el-form>
 
@@ -1072,6 +1100,11 @@
         保存
       </el-button>
     </template>
+    <aptitudeDialog
+      ref="aptitudeDialogRef"
+      @success="chooseAptitude"
+      :disabledIds="form.professions?.map(item => item.id)"
+    ></aptitudeDialog>
   </ele-modal>
 </template>
 
@@ -1090,13 +1123,21 @@
   import WithView from '@/components/upload/WithView.vue';
   import FileUpload from '@/components/upload/fileUpload.vue';
   import dictMixins from '@/mixins/dictMixins';
-
+  import aptitudeDialog from '@/views/factoryModel/jobManagement/components/aptitudeDialog.vue';
+  import { del } from 'vue';
   // D:\中赢\kd-aiot-frontend\src\views\system\user
 
   export default {
     mixins: [dictMixins],
 
-    components: { OrgSelect, RoleSelect, RegionsSelect, WithView, FileUpload },
+    components: {
+      OrgSelect,
+      RoleSelect,
+      RegionsSelect,
+      WithView,
+      FileUpload,
+      aptitudeDialog
+    },
     props: {
       // 弹窗是否打开
       visible: Boolean,
@@ -1134,10 +1175,12 @@
         workTypeId: '',
         birthday: '',
         signature: {},
-        postName:''
+        postName: '',
+        professions: []
       };
       return {
         defaultForm,
+
         // 表单数据
         form: { ...defaultForm },
         disabled: false,
@@ -1286,7 +1329,20 @@
           { value: 6, label: '离职' }
         ],
         accountList: [],
-
+        levelOptions: [
+          {
+            label: '初级',
+            value: '1'
+          },
+          {
+            label: '中级',
+            value: '2'
+          },
+          {
+            label: '高级',
+            value: '3'
+          }
+        ],
         deptTree: [],
         defaultProps: {
           multiple: true,
@@ -1723,6 +1779,80 @@
             align: 'center'
           }
         ];
+      },
+      jobColumns() {
+        return [
+          {
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center'
+          },
+          {
+            slot: 'type',
+            label: '类型',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110,
+            formatter: (_row) => {
+              return this.getDictValue('工种类型', _row.type);
+            }
+          },
+          {
+            align: 'center',
+            prop: 'code',
+            label: '编码',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            slot: 'name',
+            prop: 'name',
+            label: '名称',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            slot: 'level',
+            prop: 'level',
+            label: '等级',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110,
+            formatter: (_row) => {
+              return this.levelOptions.filter(
+                (item) => _row.level == item.value
+              )[0].label;
+            }
+          },
+          {
+            slot: 'hourCost',
+            prop: 'hourCost',
+            label: '标准工时费',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            slot: 'unit',
+            prop: 'unit',
+            label: '工时费单位',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 260,
+            align: 'center',
+            resizable: false,
+            slot: 'action',
+            showOverflowTooltip: true
+          }
+        ];
       }
     },
     created() {
@@ -1731,6 +1861,14 @@
       this.getProfessionList();
     },
     methods: {
+      chooseAptitude(data) {
+        console.log(data);
+        this.form.professions.push(...data);
+      },
+      deleteJob(index) {
+        this.form.professions.splice(index, 1);
+      },
+
       idCardChange() {
         // 检查身份证号是否为18位
         if (this.form.idCard.length === 18) {
@@ -1825,6 +1963,7 @@
         });
         this.factoryList = list || [];
       },
+
       /* 保存编辑 */
       save() {
         this.$refs.form.validate((valid) => {
@@ -1843,12 +1982,18 @@
           //
           //   this.form['deptTree'] = JSON.stringify(this.deptTree)
           // }
-
-          if (this.form.postId) {
-            this.form.postName = this.getDictValue('岗位', this.form.postId);
+          let formData = JSON.parse(JSON.stringify(this.form));
+          if (formData.postId) {
+            formData.postName = formData.postId
+              .map((item) => this.getDictValue('岗位', item))
+              .toString();
+            formData.postId = formData.postId.toString();
+          }
+          if (formData.professions?.length) {
+            formData.professionId = formData.professions.map(item=>item.id).toString();
           }
           const data = {
-            ...this.form
+            ...formData
           };
           if (!this.isUpdate) {
             delete data.id;
@@ -1910,6 +2055,9 @@
           this.getAccountList();
           if (this.data) {
             getUserDetail(this.data.id).then((res) => {
+              if (res.postId) {
+                res.postId = res.postId.split(',');
+              }
               this.form = { ...res };
               if (Array.isArray(this.form.signature)) {
                 this.form.signature = this.form.signature[0];

+ 45 - 35
src/views/system/organization/components/org-user-search.vue

@@ -7,7 +7,7 @@
     @submit.native.prevent
   >
     <el-row :gutter="24">
-      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+      <el-col v-bind="styleResponsive ? { md: 3 } : { span: 3 }">
         <el-form-item>
           <el-input
             clearable
@@ -18,7 +18,7 @@
         </el-form-item>
       </el-col>
 
-      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+      <el-col v-bind="styleResponsive ? { md: 3 } : { span: 3 }">
         <el-form-item>
           <el-input
             clearable
@@ -28,7 +28,7 @@
           />
         </el-form-item>
       </el-col>
-      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+      <el-col v-bind="styleResponsive ? { md: 3 } : { span: 3 }">
         <el-form-item>
           <el-input
             clearable
@@ -38,6 +38,16 @@
           />
         </el-form-item>
       </el-col>
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+        <DictSelection
+          dictName="岗位"
+          clearable
+          filterable
+          v-model="where.postId"
+          multiple
+        >
+        </DictSelection>
+      </el-col>
       <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
         <el-form-item>
           <el-button
@@ -65,39 +75,39 @@
 </template>
 
 <script>
-export default {
-  data() {
-    // 默认表单数据
-    const defaultWhere = {
-      jobNumber: '',
-      loginName: '',
-      name: ''
-    };
-    return {
-      // 表单数据
-      where: { ...defaultWhere }
-    };
-  },
-  computed: {
-    // 是否开启响应式布局
-    styleResponsive() {
-      return this.$store.state.theme.styleResponsive;
-    }
-  },
-  methods: {
-    /* 搜索 */
-    search() {
-      this.$emit('search', this.where);
+  export default {
+    data() {
+      // 默认表单数据
+      const defaultWhere = {
+        jobNumber: '',
+        loginName: '',
+        name: '',
+        postId:[],
+      };
+      return {
+        // 表单数据
+        where: { ...defaultWhere }
+      };
     },
-    /*  重置 */
-    reset() {
-      this.where = { ...this.defaultWhere };
-      this.search();
+    computed: {
+      // 是否开启响应式布局
+      styleResponsive() {
+        return this.$store.state.theme.styleResponsive;
+      }
     },
-    geValue() {
-      return this.where;
+    methods: {
+      /* 搜索 */
+      search() {
+        this.$emit('search', this.where);
+      },
+      /*  重置 */
+      reset() {
+        this.where = { ...this.defaultWhere };
+        this.search();
+      },
+      geValue() {
+        return this.where;
+      }
     }
-  }
-};
+  };
 </script>
-