jabin 3 лет назад
Родитель
Сommit
bbf17a4ab8

+ 3 - 18
src/views/factoryModel/plant/components/edit.vue

@@ -274,7 +274,7 @@ export default {
       enabled: 1,
       parentId: '',
       remark: '',
-      type: 4 //  FACTORY(1, "工厂"), WORKSHOP_PLAN(2, "厂房"), WORKSHOP(3, "车间"), LINE(4, "厂线");
+      type: 2 //  FACTORY(1, "工厂"), WORKSHOP_PLAN(2, "厂房"), WORKSHOP(3, "车间"), LINE(4, "厂线");
     };
     return {
       defaultForm,
@@ -417,12 +417,6 @@ export default {
         parentIdField: 'parentId'
       });
     },
-    // 获取车间
-    getListWorkshopByParentId() {
-      listWorkshopByParentId(this.form.extInfo.factoryId).then((res) => {
-        this.options.workshop = res;
-      });
-    },
     // 获取人员
     getUserPage() {
       let par = {
@@ -435,10 +429,8 @@ export default {
     },
     // 选择工厂
     change_factoryId() {
-      this.form.parentId = '';
-      this.form.groupId = '';
-      this.options.workshop = [];
-      this.getListWorkshopByParentId();
+      let result = this.options_factory.find((n) => n.id == this.form.parentId);
+      this.form.groupId = result.groupId;
     },
     // 选择负责人部门
     change_principalDep() {
@@ -446,13 +438,6 @@ export default {
       this.options.principal = [];
       this.getUserPage();
     },
-    // 选择车间
-    change_workshop() {
-      let result = this.options.workshop.find(
-        (n) => n.id == this.form.parentId
-      );
-      this.form.groupId = result.groupId;
-    },
     // 选择负责人
     change_principal() {
       let result = this.options.principal.find(

+ 2 - 2
src/views/factoryModel/plant/components/search.vue

@@ -8,12 +8,12 @@
   >
     <el-row :gutter="15">
       <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
-        <el-form-item label="产线编码:">
+        <el-form-item label="厂房编码:">
           <el-input clearable v-model="where.code" placeholder="请输入" />
         </el-form-item>
       </el-col>
       <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
-        <el-form-item label="产线名称:">
+        <el-form-item label="厂房名称:">
           <el-input clearable v-model="where.name" placeholder="请输入" />
         </el-form-item>
       </el-col>

+ 14 - 26
src/views/factoryModel/plant/index.vue

@@ -25,9 +25,6 @@
             添加
           </el-button>
         </template>
-        <template v-slot:workshop="{ row }">
-          {{ showWorkshop(row) }}
-        </template>
         <template v-slot:factory="{ row }">
           {{ showgfactory(row) }}
         </template>
@@ -87,21 +84,25 @@ export default {
         },
         {
           prop: 'code',
-          label: '产线编码'
+          label: '厂房编码'
         },
         {
-          label: '产线名称',
+          label: '厂房名称',
           prop: 'name'
         },
         {
-          label: '所属工厂',
-          prop: 'extInfo.factoryId',
-          slot: 'factory'
+          label: '状态',
+          prop: 'enabled',
+          slot: 'enabled'
         },
         {
-          label: '所属车间',
-          prop: 'parentId',
-          slot: 'workshop'
+          label: '联系方式',
+          prop: 'extInfo.phone'
+        },
+        {
+          label: '所属工厂',
+          prop: 'extInfo.parentId',
+          slot: 'factory'
         },
         {
           label: '省/市/区',
@@ -111,11 +112,7 @@ export default {
           label: '详细地址',
           prop: 'extInfo.locationDetail'
         },
-        {
-          label: '状态',
-          prop: 'enabled',
-          slot: 'enabled'
-        },
+
         {
           columnKey: 'action',
           label: '操作',
@@ -146,7 +143,7 @@ export default {
         ...where,
         pageNum: page,
         size: limit,
-        type: 4
+        type: 2
       });
     },
     search(where) {
@@ -167,15 +164,6 @@ export default {
     },
     // 回显工厂名称
     showgfactory(row) {
-      let result = row.parent.find((n) => n.id == row.extInfo.factoryId);
-      if (result) {
-        return result.name;
-      } else {
-        return '';
-      }
-    },
-    // 回显车间
-    showWorkshop(row) {
       let result = row.parent.find((n) => n.id == row.parentId);
       if (result) {
         return result.name;

+ 284 - 105
src/views/factoryModel/station/components/edit.vue

@@ -7,16 +7,12 @@
     :before-close="handleClose"
     :close-on-click-modal="false"
     :close-on-press-escape="false"
-    width="1000px"
+    width="1200px"
   >
     <el-form ref="form" :model="form" :rules="rules" label-width="100px">
       <el-row>
         <el-col :span="8">
-          <el-form-item
-            label="工厂编码:"
-            prop="code"
-            style="margin-bottom: 22px"
-          >
+          <el-form-item label="工位编码:" prop="code">
             <el-input
               clearable
               :maxlength="20"
@@ -26,11 +22,7 @@
           </el-form-item>
         </el-col>
         <el-col :span="8">
-          <el-form-item
-            label="工厂名称:"
-            prop="name"
-            style="margin-bottom: 22px"
-          >
+          <el-form-item label="工位名称:" prop="name">
             <el-input
               clearable
               :maxlength="20"
@@ -40,61 +32,145 @@
           </el-form-item>
         </el-col>
         <el-col :span="8">
-          <el-form-item
-            label="所属公司:"
-            prop="groupId"
-            style="margin-bottom: 22px"
-          >
+          <el-form-item label="所属工厂:" prop="extInfo.factoryId">
+            <el-select
+              v-model="form.extInfo.factoryId"
+              placeholder="请选择"
+              @change="change_factoryId"
+              style="width: 100%"
+            >
+              <el-option
+                v-for="item in options_factory"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="所属车间:" prop="parentId">
+            <el-select
+              v-model="form.parentId"
+              placeholder="请选择"
+              style="width: 100%"
+              @change="change_workshop"
+            >
+              <el-option
+                v-for="item in options.workshop"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="所属产线:" prop="parentId">
+            <el-select
+              v-model="form.parentId"
+              placeholder="请选择"
+              style="width: 100%"
+              @change="change_workshop"
+            >
+              <el-option
+                v-for="item in options.workshop"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="负责人部门:" prop="extInfo.principalDep">
             <ele-tree-select
               clearable
-              :data="options.groupId"
-              v-model="form.groupId"
+              :data="options.principalDep"
+              v-model="form.extInfo.principalDep"
               valueKey="id"
               labelKey="name"
               placeholder="请选择"
+              @change="change_principalDep"
               default-expand-all
             />
           </el-form-item>
         </el-col>
-        <el-col :span="16" style="margin-bottom: 22px">
-          <el-form-item label="地址:" prop="location_city">
-            <div class="location-warp">
-              <el-cascader
-                clearable
-                style="width: 385px"
-                v-model="form.location"
-                :options="options.cityDataLabel"
-              ></el-cascader>
+        <el-col :span="8">
+          <el-form-item label="负责人:" prop="extInfo.principal">
+            <el-select
+              v-model="form.extInfo.principal"
+              placeholder="请选择"
+              @change="change_principal"
+              style="width: 100%"
+            >
+              <el-option
+                v-for="item in options.principal"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="8">
+          <el-form-item label="节拍时间:" prop="extInfo.meterTime">
+            <div class="workMeter-warp">
               <el-input
-                class="detail"
+                class="s1"
                 clearable
                 :maxlength="20"
-                v-model="form.locationDetail"
-                placeholder="请输入详细地址"
+                v-model="form.extInfo.meterTime"
+                placeholder="请输入"
               />
-            </div>
-          </el-form-item>
-        </el-col>
-        <el-col :span="8" style="margin-bottom: 22px">
-          <el-form-item label="状态:" prop="enabled">
-            <div class="location-warp">
-              <el-select
-                v-model="form.enabled"
-                v
-                placeholder="请选择"
-                style="width: 100%"
-              >
+              <el-select class="s2" v-model="form.enabled" placeholder="请选择">
                 <el-option
-                  v-for="item in options.zt"
+                  v-for="item in options.meterTimeUnit"
                   :key="item.value"
                   :label="item.label"
                   :value="item.value"
                 >
                 </el-option>
               </el-select>
+              <span class="s3">/次</span>
             </div>
           </el-form-item>
         </el-col>
+
+        <el-col :span="8">
+          <el-form-item label="状态:" prop="enabled">
+            <el-select
+              v-model="form.enabled"
+              placeholder="请选择"
+              style="width: 100%"
+            >
+              <el-option
+                v-for="item in options.enabled"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="24">
+          <el-form-item label="备注:" prop="remark">
+            <el-input
+              clearable
+              :maxlength="100"
+              type="textarea"
+              v-model="form.remark"
+              placeholder="请输入"
+            />
+          </el-form-item>
+        </el-col>
       </el-row>
     </el-form>
     <template v-slot:footer>
@@ -107,21 +183,45 @@
 </template>
 
 <script>
-import { cityDataLabel } from 'ele-admin/packages/utils/regions';
-import { listOrganizations } from '@/api/system/organization';
-import { saveOrUpdate } from '@/api/factoryModel';
+import { listWorkshopByParentId } from '@/api/factoryModel';
+import { getUserPage } from '@/api/system/organization';
 export default {
+  props: {
+    options_groupId: {
+      type: Array,
+      default() {
+        return [];
+      }
+    },
+    options_factory: {
+      type: Array,
+      default() {
+        return [];
+      }
+    }
+  },
+  watch: {
+    options_groupId(nval) {
+      this.toTreeData(nval);
+    }
+  },
   data() {
     const defaultForm = {
       id: '',
       code: '',
       name: '',
-      groupId: '',
-      locationDetail: '',
-      location: [],
+      extInfo: {
+        factoryId: '',
+        principal: '', // 负责人
+        principalDep: '', // 负责人部门
+        locationDetail: '', // 详细地址
+        location: [], // 省市区
+        meterTimeUnit: '时', // 节拍时间单位
+        meterTime: '' // 节拍时间
+      },
       enabled: 1,
-      parentId: '',
-      type: 1 //  FACTORY(1, "工厂"), WORKSHOP_PLAN(2, "厂房"), WORKSHOP(3, "车间"), LINE(4, "厂线");
+      productionLineId: '',
+      remark: ''
     };
     return {
       defaultForm,
@@ -131,13 +231,28 @@ export default {
       rules: {
         code: [{ required: true, message: '请输入', trigger: 'blur' }],
         name: [{ required: true, message: '请输入', trigger: 'blur' }],
-        groupId: [{ required: true, message: '请输入', trigger: 'blur' }]
+        'extInfo.factoryId': [
+          { required: true, message: '请输入', trigger: 'change' }
+        ],
+        parentId: { required: true, message: '请输入', trigger: 'change' },
+        'extInfo.principalDep': [
+          { required: true, message: '请输入', trigger: 'change' }
+        ],
+        'extInfo.principal': [
+          { required: true, message: '请输入', trigger: 'change' }
+        ],
+        'extInfo.phone': [
+          { min: 11, message: '手机号格式不正确', trigger: 'blur' }
+        ]
       },
       visible: false,
       type: '', // add/edit
       loading: false,
       options: {
-        zt: [
+        principalDep: [],
+        principal: [],
+        workshop: [],
+        enabled: [
           {
             label: '生效',
             value: 1
@@ -147,8 +262,24 @@ export default {
             value: 0
           }
         ],
-        groupId: [],
-        cityDataLabel
+        meterTimeUnit: [
+          {
+            value: '时',
+            label: '时'
+          },
+          {
+            value: '分',
+            label: '分'
+          },
+          {
+            value: '秒',
+            label: '秒'
+          },
+          {
+            value: '日',
+            label: '日'
+          }
+        ]
       }
     };
   },
@@ -156,33 +287,37 @@ export default {
     title() {
       switch (this.type) {
         case 'add':
-          return '新增工';
+          return '新增工';
           break;
         case 'edit':
-          return '编辑工';
+          return '编辑工';
           break;
         default:
           break;
       }
     }
   },
-  created() {
-    this.getGs();
-  },
   methods: {
     open(type, row) {
       this.type = type;
       this.visible = true;
       if (type == 'edit') {
-        this.form.id = row.id;
-        this.form.code = row.code;
-        this.form.name = row.name;
-        this.form.groupId = row.groupId;
-        this.form.enabled = row.enabled;
-        this.form.parentId = row.parentId;
-        this.form.type = row.type;
-        this.form.location = row.extInfo.location.split('/');
-        this.form.locationDetail = row.extInfo.locationDetail;
+        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 (this.form.extInfo.factoryId) {
+          this.getListWorkshopByParentId();
+        }
+        if (this.form.extInfo.principalDep) {
+          this.getUserPage();
+        }
       }
     },
     /* 保存编辑 */
@@ -193,30 +328,20 @@ export default {
         }
         this.loading = true;
 
-        const data = {
-          code: this.form.code,
-          name: this.form.name,
-          groupId: this.form.groupId,
-          enabled: this.form.enabled,
-          parentId: this.form.groupId,
-          type: this.form.type,
-          extInfo: this.setLocation()
-        };
-        if (this.type == 'edit') {
-          data.id = this.form.id;
+        if (this.type == 'add') {
+          delete this.form.id;
         }
-        console.log(data);
-        saveOrUpdate(data)
-          .then((msg) => {
-            this.loading = false;
-            this.$message.success(msg);
-            this.handleClose();
-            this.$emit('done');
-          })
-          .catch((e) => {
-            this.loading = false;
-            this.$message.error(e.message);
-          });
+        // 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() {
@@ -227,22 +352,56 @@ export default {
       this.restForm();
       this.visible = false;
     },
-    // 获取公司数据
-    getGs() {
-      listOrganizations().then((list) => {
-        console.log(list);
-        this.options.groupId = this.$util.toTreeData({
-          data: list,
-          idField: 'id',
-          parentIdField: 'parentId'
-        });
+    // 格式化公司数据
+    toTreeData(val) {
+      this.options.principalDep = this.$util.toTreeData({
+        data: val,
+        idField: 'id',
+        parentIdField: 'parentId'
+      });
+    },
+    // 获取车间
+    getListWorkshopByParentId() {
+      listWorkshopByParentId(this.form.extInfo.factoryId).then((res) => {
+        this.options.workshop = res;
       });
     },
-    setLocation() {
-      return {
-        location: this.form.location.join('/'),
-        locationDetail: this.form.locationDetail
+    // 获取人员
+    getUserPage() {
+      let par = {
+        groupId: this.form.extInfo.principalDep,
+        size: 999
       };
+      getUserPage(par).then((res) => {
+        this.options.principal = res.list;
+      });
+    },
+    // 选择工厂
+    change_factoryId() {
+      this.form.parentId = '';
+      this.form.groupId = '';
+      this.options.workshop = [];
+      this.getListWorkshopByParentId();
+    },
+    // 选择负责人部门
+    change_principalDep() {
+      this.form.extInfo.principal = '';
+      this.options.principal = [];
+      this.getUserPage();
+    },
+    // 选择车间
+    change_workshop() {
+      let result = this.options.workshop.find(
+        (n) => n.id == this.form.parentId
+      );
+      this.form.groupId = result.groupId;
+    },
+    // 选择负责人
+    change_principal() {
+      let result = this.options.principal.find(
+        (n) => n.id == this.form.extInfo.principal
+      );
+      this.form.extInfo.phone = result.phone;
     }
   }
 };
@@ -254,4 +413,24 @@ export default {
     margin-left: 10px;
   }
 }
+.workMeter-warp {
+  .s1 {
+    width: 40%;
+  }
+  .s2 {
+    width: 40%;
+    margin-left: 10px;
+  }
+  .s3 {
+    margin-left: 10px;
+  }
+}
+:deep(
+    .el-dialog:not(.ele-dialog-form)
+      .el-dialog__body
+      .el-form
+      .el-form-item:last-child
+  ) {
+  margin-bottom: 22px;
+}
 </style>

+ 34 - 34
src/views/factoryModel/station/components/search.vue

@@ -7,34 +7,17 @@
     @submit.native.prevent
   >
     <el-row :gutter="15">
-      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
-        <el-form-item label="工厂编码:">
+      <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
+        <el-form-item label="产线编码:">
           <el-input clearable v-model="where.code" placeholder="请输入" />
         </el-form-item>
       </el-col>
-      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
-        <el-form-item label="工厂名称:">
+      <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
+        <el-form-item label="产线名称:">
           <el-input clearable v-model="where.name" placeholder="请输入" />
         </el-form-item>
       </el-col>
-      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
-        <el-form-item label="状态:">
-          <el-select
-            v-model="where.enable"
-            class="m-2"
-            placeholder="请选择"
-            size="large"
-          >
-            <el-option
-              v-for="item in options.state"
-              :key="item.value"
-              :label="item.label"
-              :value="item.value"
-            />
-          </el-select>
-        </el-form-item>
-      </el-col>
-      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
+      <el-col v-bind="styleResponsive ? { lg: 4, md: 12 } : { span: 4 }">
         <div class="ele-form-actions">
           <el-button
             type="primary"
@@ -53,28 +36,37 @@
 
 <script>
 export default {
+  props: {
+    options_groupId: {
+      type: Array,
+      default() {
+        return [];
+      }
+    },
+    options_factory: {
+      type: Array,
+      default() {
+        return [];
+      }
+    }
+  },
+  watch: {
+    options_groupId(nval) {
+      this.toTreeData(nval);
+    }
+  },
   data() {
     // 默认表单数据
     const defaultWhere = {
       code: '',
-      name: '',
-      enable: ''
+      name: ''
     };
     return {
       defaultWhere,
       // 表单数据
       where: { ...defaultWhere },
       options: {
-        state: [
-          {
-            label: '生效',
-            value: 1
-          },
-          {
-            label: '失效',
-            value: 0
-          }
-        ]
+        groupId: []
       }
     };
   },
@@ -94,6 +86,14 @@ export default {
       console.log(this.defaultWhere);
       this.where = { ...this.defaultWhere };
       this.search();
+    },
+    // 格式化公司数据
+    toTreeData(val) {
+      this.options.groupId = this.$util.toTreeData({
+        data: val,
+        idField: 'id',
+        parentIdField: 'parentId'
+      });
     }
   }
 };

+ 55 - 16
src/views/factoryModel/station/index.vue

@@ -1,7 +1,12 @@
 <template>
   <div class="ele-body">
     <el-card shadow="never">
-      <search ref="search" @search="search"></search>
+      <search
+        ref="search"
+        @search="search"
+        :options_groupId="dict.groupId"
+        :options_factory="dict.factory"
+      ></search>
       <ele-pro-table
         ref="table"
         :columns="columns"
@@ -20,12 +25,15 @@
             添加
           </el-button>
         </template>
+        <template v-slot:workshop="{ row }">
+          {{ showWorkshop(row) }}
+        </template>
+        <template v-slot:factory="{ row }">
+          {{ showgfactory(row) }}
+        </template>
         <template v-slot:enabled="{ row }">
           {{ dict.enabled[row.enabled] }}
         </template>
-        <template v-slot:groupId="{ row }">
-          {{ showgroupName(row.groupId) }}
-        </template>
         <!-- 操作列 -->
         <template v-slot:action="{ row }">
           <el-link
@@ -50,7 +58,12 @@
         </template>
       </ele-pro-table>
     </el-card>
-    <edit ref="edit" @done="done"></edit>
+    <edit
+      ref="edit"
+      @done="done"
+      :options_groupId="dict.groupId"
+      :options_factory="dict.factory"
+    ></edit>
   </div>
 </template>
 <script>
@@ -74,16 +87,21 @@ export default {
         },
         {
           prop: 'code',
-          label: '工厂编码'
+          label: '产线编码'
         },
         {
-          label: '工厂名称',
+          label: '产线名称',
           prop: 'name'
         },
         {
-          label: '所属公司',
-          prop: 'groupId',
-          slot: 'groupId'
+          label: '所属工厂',
+          prop: 'extInfo.factoryId',
+          slot: 'factory'
+        },
+        {
+          label: '所属车间',
+          prop: 'parentId',
+          slot: 'workshop'
         },
         {
           label: '省/市/区',
@@ -109,16 +127,18 @@ export default {
         }
       ],
       dict: {
+        groupId: [],
+        factory: [],
         enabled: {
           1: '生效',
           0: '未生效'
-        },
-        groupId: []
+        }
       }
     };
   },
   created() {
     this.getGs();
+    this.getFactoryarea();
   },
   methods: {
     datasource({ page, where, limit }) {
@@ -126,7 +146,7 @@ export default {
         ...where,
         pageNum: page,
         size: limit,
-        type: 1
+        type: 4
       });
     },
     search(where) {
@@ -145,15 +165,34 @@ export default {
         this.dict.groupId = list;
       });
     },
-    // 回显公司名称
-    showgroupName(id) {
-      let result = this.dict.groupId.find((n) => n.id == id);
+    // 回显工厂名称
+    showgfactory(row) {
+      let result = row.parent.find((n) => n.id == row.extInfo.factoryId);
       if (result) {
         return result.name;
       } else {
         return '';
       }
     },
+    // 回显车间
+    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
+      };
+      getFactoryarea(par).then((res) => {
+        this.dict.factory = res.list;
+      });
+    },
     remove(row) {
       deletefactoryarea(row.id)
         .then((message) => {