ysy пре 1 година
родитељ
комит
530cfff376
2 измењених фајлова са 266 додато и 208 уклоњено
  1. 263 199
      src/views/factoryModel/workshop/components/edit.vue
  2. 3 9
      src/views/factoryModel/workshop/index.vue

+ 263 - 199
src/views/factoryModel/workshop/components/edit.vue

@@ -57,18 +57,39 @@
           </el-form-item>
         </el-col>
         <el-col :span="12">
+          <el-form-item label="所属工厂:" prop="factoryId">
+            <el-select
+              style="margin-bottom: 22px; width: 100%"
+              clearable
+              v-model="form.factoryId"
+              @change="change_factoryId"
+              filterable
+              placeholder="请选择所属工厂"
+            >
+              <el-option
+                v-for="item in factoryList"
+                :label="item.name"
+                :value="item.id"
+                :key="item.id"
+              ></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
 
-
-          <el-form-item label="所属厂房:" prop="parentId" style="margin-bottom: 22px">
+        <el-col :span="12">
+          <el-form-item
+            label="所属厂房:"
+            prop="parentId"
+            style="margin-bottom: 22px"
+          >
             <el-select
               v-model="form.parentId"
               filterable
               placeholder="请选择所属厂房"
               style="width: 100%"
             >
-
               <el-option
-                v-for="item in options_factory"
+                v-for="item in workshopPlanList"
                 :key="item.id"
                 :label="item.pathName"
                 :value="item.id"
@@ -77,8 +98,11 @@
             </el-select>
           </el-form-item>
         </el-col>
+
         <el-col :span="12">
-          <el-form-item label="负责人部门:" prop="extInfo.principalDep"
+          <el-form-item
+            label="负责人部门:"
+            prop="extInfo.principalDep"
             style="margin-bottom: 22px"
           >
             <deptSelect
@@ -89,7 +113,9 @@
           </el-form-item>
         </el-col>
         <el-col :span="12">
-          <el-form-item label="负责人:" prop="leaderId"
+          <el-form-item
+            label="负责人:"
+            prop="leaderId"
             style="margin-bottom: 22px"
           >
             <personSelect
@@ -110,7 +136,9 @@
           </el-form-item>
         </el-col>
         <el-col :span="12">
-          <el-form-item label="地址:" prop="location_city"
+          <el-form-item
+            label="地址:"
+            prop="location_city"
             style="margin-bottom: 22px"
           >
             <el-input
@@ -133,214 +161,250 @@
 </template>
 
 <script>
-import { saveOrUpdate } from '@/api/factoryModel';
-import { getUserPage } from '@/api/system/organization';
-import deptSelect from '@/components/CommomSelect/dept-select.vue';
-import personSelect from '@/components/CommomSelect/person-select.vue';
-import AreaSelect from "@/views/enterpriseModel/regionalManage/components/area-cascader.vue";
-import {basicAreaPageAPI} from "@/api/regionalManage";
-export default {
-  props: {
-    options_groupId: {
-      type: Array,
-      default() {
-        return [];
+  import { saveOrUpdate } from '@/api/factoryModel';
+  import { getUserPage } from '@/api/system/organization';
+  import deptSelect from '@/components/CommomSelect/dept-select.vue';
+  import personSelect from '@/components/CommomSelect/person-select.vue';
+  import AreaSelect from '@/views/enterpriseModel/regionalManage/components/area-cascader.vue';
+  import { basicAreaPageAPI } from '@/api/regionalManage';
+  import { getFactoryarea } from '@/api/factoryModel';
+  export default {
+    props: {
+      options_groupId: {
+        type: Array,
+        default() {
+          return [];
+        }
       }
     },
-    options_factory: {
-      type: Array,
-      default() {
-        return [];
+    watch: {
+      options_groupId(nval) {
+        this.toTreeData(nval);
       }
-    }
-  },
-  watch: {
-    options_groupId(nval) {
-      this.toTreeData(nval);
-    }
-  },
-  components: {
-    AreaSelect,
-    deptSelect,
-    personSelect
-  },
-  created() {
-    this.getBasicAreaList();
-  },
-  data() {
-    const defaultForm = function () {
+    },
+    components: {
+      AreaSelect,
+      deptSelect,
+      personSelect
+    },
+    created() {
+      this.getFactoryList();
+      this.getBasicAreaList();
+    },
+    data() {
+      const defaultForm = function () {
+        return {
+          id: '',
+          code: '',
+          name: '',
+          areaId: '',
+          areaName: '',
+          extInfo: {
+            location: '',
+            principalDep: '' // 负责人部门
+          },
+          leaderId: '', // 负责人
+          groupId: '',
+          enabled: 1,
+          factoryId: '',
+          parentId: '',
+          type: 3 //  FACTORY(1, "工厂"), WORKSHOP_PLAN(2, "厂房"), WORKSHOP(3, "车间"), LINE(4, "厂线");
+        };
+      };
       return {
-        id: '',
-        code: '',
-        name: '',
-        areaId: '',
-        areaName: '',
-        extInfo: {
-          location: '',
-          principalDep: '' // 负责人部门
+        defaultForm,
+        // 表单数据
+        form: { ...defaultForm() },
+        // 表单验证规则
+        rules: {
+          code: [
+            { required: true, message: '请输入车间编码', trigger: 'blur' }
+          ],
+          name: [
+            { required: true, message: '请输入车间名称', trigger: 'blur' }
+          ],
+          groupId: [
+            { required: true, message: '请选择所属公司', trigger: 'change' }
+          ],
+          parentId: [
+            { required: true, message: '请选择所属工厂', trigger: 'change' }
+          ],
+          leaderId: {
+            required: true,
+            message: '请选择负责人',
+            trigger: 'change'
+          },
+          'extInfo.principalDep': [
+            { required: true, message: '请选择负责人部门', trigger: 'change' }
+          ]
         },
-        leaderId: '', // 负责人
-        groupId: '',
-        enabled: 1,
-        parentId: '',
-        type: 3 //  FACTORY(1, "工厂"), WORKSHOP_PLAN(2, "厂房"), WORKSHOP(3, "车间"), LINE(4, "厂线");
-      };
-    };
-    return {
-      defaultForm,
-      // 表单数据
-      form: { ...defaultForm() },
-      // 表单验证规则
-      rules: {
-        code: [{ required: true, message: '请输入车间编码', trigger: 'blur' }],
-        name: [{ required: true, message: '请输入车间名称', trigger: 'blur' }],
-        groupId: [{ required: true, message: '请选择所属公司', trigger: 'change' }],
-        parentId: [{ required: true, message: '请选择所属工厂', trigger: 'change' }],
-        leaderId: {
-          required: true,
-          message: '请选择负责人',
-          trigger: 'change'
+        visible: false,
+        type: '', // add/edit
+        loading: false,
+        areaList: [],
+        areaTreeList: [],
+        options: {
+          groupId: [],
+          leaderId: []
         },
-        'extInfo.principalDep': [
-          { required: true, message: '请选择负责人部门', trigger: 'change' }
-        ]
-      },
-      visible: false,
-      type: '', // add/edit
-      loading: false,
-      areaList: [],
-      areaTreeList: [],
-      options: {
-        groupId: [],
-        leaderId: []
-      }
-    };
-  },
-  computed: {
-    title() {
-      switch (this.type) {
-        case 'add':
-          return '新增车间';
-          break;
-        case 'edit':
-          return '编辑车间';
-          break;
-        default:
-          break;
+        factoryList: [],
+        workshopPlanList: []
+      };
+    },
+    computed: {
+      title() {
+        switch (this.type) {
+          case 'add':
+            return '新增车间';
+            break;
+          case 'edit':
+            return '编辑车间';
+            break;
+          default:
+            break;
+        }
       }
-    }
-  },
-  methods: {
-    open(type, row) {
-      this.type = type;
-      this.visible = true;
-      if (type == 'edit') {
-        for (const key of Object.keys(this.form)) {
-          if (key !== 'extInfo') {
-            this.form[key] = row[key];
-          } else {
-            for (const el of Object.keys(this.form.extInfo)) {
-              this.form.extInfo[el] = row.extInfo[el];
+    },
+    methods: {
+      open(type, row) {
+        this.type = type;
+        this.visible = true;
+        if (type == 'edit') {
+          for (const key of Object.keys(this.form)) {
+            if (key !== 'extInfo') {
+              this.form[key] = row[key];
+            } else {
+              for (const el of Object.keys(this.form.extInfo)) {
+                this.form.extInfo[el] = row.extInfo[el];
+              }
             }
           }
+          if (row.extInfo.principalDep) {
+            const params = { executeGroupId: row.extInfo.principalDep };
+            this.$nextTick(() => {
+              this.$refs.directorRef.getList(params);
+            });
+          }
+
+          this.getlistCf();
         }
-        if(row.extInfo.principalDep){
-           const params = { executeGroupId: row.extInfo.principalDep };
-           this.$nextTick(() => {
-             this.$refs.directorRef.getList(params);
-           });
-        }
-      }
-    },
-    /* 获取区域集合 */
-    async getBasicAreaList() {
-      this.areaList = await basicAreaPageAPI(
-        {
+      },
+
+      async getFactoryList() {
+        const { list } = await getFactoryarea({
           pageNum: 1,
+          size: 999,
+          type: 1
+        });
+        this.factoryList = list || [];
+      },
+
+      change_factoryId() {
+        this.form.workshopPlanId = '';
+        this.workshopPlanList = [];
+
+        this.getlistCf();
+
+      },
+
+      
+      getlistCf() {
+        let par = {
+          type: 2,
+          parentId: this.form.factoryId,
           size: 9999
-        }
-      )
-      this.areaTreeList = this.$util.toTreeData({
-        data: this.areaList,
-        idField: 'id',
-        parentIdField: 'parentId'
-      });
+        };
+        getFactoryarea(par).then((res) => {
+          this.workshopPlanList = res.list;
+        });
+      },
 
-    },
-    getAreaInfo(nodeInfo) {
-      this.form.areaName = nodeInfo[0]?.pathLabels.join('/') || ''
-      this.form.areaId = this.form.areaId || ''
-    },
-    /* 保存编辑 */
-    save() {
-      this.$refs.form.validate((valid) => {
-        if (!valid) {
-          return false;
-        }
-        this.loading = true;
+      /* 获取区域集合 */
+      async getBasicAreaList() {
+        this.areaList = await basicAreaPageAPI({
+          pageNum: 1,
+          size: 9999
+        });
+        this.areaTreeList = this.$util.toTreeData({
+          data: this.areaList,
+          idField: 'id',
+          parentIdField: 'parentId'
+        });
+      },
+      getAreaInfo(nodeInfo) {
+        this.form.areaName = nodeInfo[0]?.pathLabels.join('/') || '';
+        this.form.areaId = this.form.areaId || '';
+      },
+      /* 保存编辑 */
+      save() {
+        this.$refs.form.validate((valid) => {
+          if (!valid) {
+            return false;
+          }
+          this.loading = true;
 
-        if (this.type == 'add') {
-          delete this.form.id;
-        }
+          if (this.type == 'add') {
+            delete this.form.id;
+          }
 
-        saveOrUpdate(this.form)
-          .then((msg) => {
-            this.loading = false;
-            this.$message.success(msg);
-            this.handleClose();
-            this.$emit('done');
-          })
-          .catch((e) => {
-            this.loading = false;
-            this.$message.error(e.message);
-          });
-      });
-    },
-    restForm() {
-      this.form = { ...this.defaultForm() };
-      this.$nextTick(() => {
-        this.$refs.form.clearValidate();
-      });
-    },
-    handleClose() {
-      this.restForm();
-      this.visible = false;
-    },
-    // 格式化公司数据
-    toTreeData(val) {
-      this.options.groupId = this.$util.toTreeData({
-        data: val,
-        idField: 'id',
-        parentIdField: 'parentId'
-      });
-    },
-    // 选择负责人部门
-    change_principalDep(id,info) {
-      this.form.leaderId = '';
-      // 根据部门获取人员
-      const params = { groupId: id };
-      this.$nextTick(() => {
-        this.$refs.directorRef.getList(params);
-      });
-    },
-    // 获取人员
-    // getUserPage() {
-    //   let par = {
-    //     groupId: this.form.extInfo.principalDep,
-    //     size: 999
-    //   };
-    //   getUserPage(par).then((res) => {
-    //     this.options.leaderId = res.list;
-    //   });
-    // }
-  }
-};
+          saveOrUpdate(this.form)
+            .then((msg) => {
+              this.loading = false;
+              this.$message.success(msg);
+              this.handleClose();
+              this.$emit('done');
+            })
+            .catch((e) => {
+              this.loading = false;
+              this.$message.error(e.message);
+            });
+        });
+      },
+      restForm() {
+        this.form = { ...this.defaultForm() };
+        this.$nextTick(() => {
+          this.$refs.form.clearValidate();
+        });
+      },
+      handleClose() {
+        this.restForm();
+        this.visible = false;
+      },
+      // 格式化公司数据
+      toTreeData(val) {
+        this.options.groupId = this.$util.toTreeData({
+          data: val,
+          idField: 'id',
+          parentIdField: 'parentId'
+        });
+      },
+      // 选择负责人部门
+      change_principalDep(id, info) {
+        this.form.leaderId = '';
+        // 根据部门获取人员
+        const params = { groupId: id };
+        this.$nextTick(() => {
+          this.$refs.directorRef.getList(params);
+        });
+      }
+      // 获取人员
+      // getUserPage() {
+      //   let par = {
+      //     groupId: this.form.extInfo.principalDep,
+      //     size: 999
+      //   };
+      //   getUserPage(par).then((res) => {
+      //     this.options.leaderId = res.list;
+      //   });
+      // }
+    }
+  };
 </script>
 <style lang="scss" scoped>
-.location-warp {
-  display: flex;
-  .detail {
-    margin-left: 10px;
+  .location-warp {
+    display: flex;
+    .detail {
+      margin-left: 10px;
+    }
   }
-}
 </style>

+ 3 - 9
src/views/factoryModel/workshop/index.vue

@@ -29,10 +29,6 @@
           {{ showgroupName(row.groupId) }}
         </template>
 
-        <template v-slot:parent="{ row }">
-          {{ showgfactory(row, 2) }}
-        </template>
-
         <template v-slot:factory="{ row }">
           <!-- {{ showgfactory(row, 1) }} -->
           {{  pathFn(row.pathName) }}
@@ -66,7 +62,6 @@
       ref="edit"
       @done="done"
       :options_groupId="dict.groupId"
-      :options_factory="dict.factory"
     ></edit>
   </div>
 </template>
@@ -103,13 +98,12 @@
             slot: 'groupId'
           },
           {
-            label: '工厂编码',
-            prop: 'parentCode',
-            slot: 'parent'
+            label: '所属工厂',
+            prop: 'factoryName',
 
           },
           {
-            label: '所属工厂 - 厂房',
+            label: '所属厂房',
             prop: 'parentId',
             slot: 'factory'
           },