Pārlūkot izejas kodu

Merge branch 'dev' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend into dev

LAPTOP-16IUEB3P\Lenovo 2 gadi atpakaļ
vecāks
revīzija
876bce19ee

+ 79 - 81
src/api/factoryModel/index.js

@@ -1,99 +1,97 @@
 import request from '@/utils/request';
 // 获取车间下的所有产线
-export async function listFactoryLineByParentId(params) {
-    const res = await request.get(
-        `/main/factoryarea/listFactoryLineByParentId/${params}`, {}
-    );
-    if (res.data.code == 0) {
-        return res.data.data;
-    }
-    return Promise.reject(new Error(res.data.message));
+export async function listFactoryLineByParentId (params) {
+  const res = await request.get(
+    `/main/factoryarea/listFactoryLineByParentId/${params}`,
+    {}
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
 }
 // 获取工厂下的所有车间
-export async function listWorkshopByParentId(params) {
-    const res = await request.get(
-        `/main/factoryarea/listWorkshopByParentId/${params}`, {}
-    );
-    if (res.data.code == 0) {
-        return res.data.data;
-    }
-    return Promise.reject(new Error(res.data.message));
+export async function listWorkshopByParentId (params) {
+  const res = await request.get(
+    `/main/factoryarea/listWorkshopByParentId/${params}`,
+    {}
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
 }
 // 保存
-export async function saveOrUpdate(params) {
-    const res = await request.post(
-        `/main/factoryarea/saveOrUpdate`,
-        params
-    );
-    if (res.data.code == 0) {
-        return res.data.message;
-    }
-    return Promise.reject(new Error(res.data.message));
+export async function saveOrUpdate (params) {
+  const res = await request.post(`/main/factoryarea/saveOrUpdate`, params);
+  if (res.data.code == 0) {
+    return res.data.message;
+  }
+  return Promise.reject(new Error(res.data.message));
 }
 // 查询工厂列表-分页
-export async function getFactoryarea(params) {
-    const res = await request.get(
-        `/main/factoryarea/page`,
-        {
-            params
-        }
-    );
-    if (res.data.code == 0) {
-        return res.data.data;
-    }
-    return Promise.reject(new Error(res.data.message));
+export async function getFactoryarea (params) {
+  const res = await request.get(`/main/factoryarea/page`, {
+    params
+  });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
 }
 // 删除
-export async function deletefactoryarea(params) {
-    const res = await request.get(
-        `/main/factoryarea/delete/${params}`,
-    );
-    if (res.data.code == 0) {
-        return res.data.message;
-    }
-    return Promise.reject(new Error(res.data.message));
+export async function deletefactoryarea (params) {
+  const res = await request.get(`/main/factoryarea/delete/${params}`);
+  if (res.data.code == 0) {
+    return res.data.message;
+  }
+  return Promise.reject(new Error(res.data.message));
 }
 // 保存修改工位
-export async function saveOrUpdate_gw(params) {
-    const res = await request.post(
-        `/main/factoryworkstation/saveOrUpdate`,
-        params
-    );
-    if (res.data.code == 0) {
-        return res.data.message;
-    }
-    return Promise.reject(new Error(res.data.message));
+export async function saveOrUpdate_gw (params) {
+  const res = await request.post(
+    `/main/factoryworkstation/saveOrUpdate`,
+    params
+  );
+  if (res.data.code == 0) {
+    return res.data.message;
+  }
+  return Promise.reject(new Error(res.data.message));
 }
 // 工位分页查询
-export async function getFactoryworkstation(params) {
-    const res = await request.get(
-        `/main/factoryworkstation/page`,
-        {
-            params
-        }
-    );
-    if (res.data.code == 0) {
-        return res.data.data;
-    }
-    return Promise.reject(new Error(res.data.message));
+export async function getFactoryworkstation (params) {
+  const res = await request.get(`/main/factoryworkstation/page`, {
+    params
+  });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
 }
 // 工位删除
-export async function deleteFactoryworkstation(params) {
-    const res = await request.delete(
-        `/main/factoryworkstation/delete/${params}`,
-    );
-    if (res.data.code == 0) {
-        return res.data.message;
-    }
-    return Promise.reject(new Error(res.data.message));
+export async function deleteFactoryworkstation (params) {
+  const res = await request.delete(`/main/factoryworkstation/delete/${params}`);
+  if (res.data.code == 0) {
+    return res.data.message;
+  }
+  return Promise.reject(new Error(res.data.message));
 }
 // 工位详情
-export async function getById(params) {
-    const res = await request.get(
-        `/main/factoryworkstation/getById/${params}`,
-    );
-    if (res.data.code == 0) {
-        return res.data.data;
-    }
-    return Promise.reject(new Error(res.data.message));
-}
+export async function getById (params) {
+  const res = await request.get(`/main/factoryworkstation/getById/${params}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+// 工艺路线工序实例-列表(查询所有)
+export async function getProduceList (params) {
+  const res = await request.get(
+    `/main/producerouting/taskinstance/getAllList`,
+    { params }
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 1 - 1
src/main.js

@@ -73,7 +73,7 @@ export async function bootstrap () {
 export async function mount (props) {
   console.log('[vue] props from main framework', props);
 
-  initParentStore(props.store);
+  initParentStore(props.store?.state);
   props.onGlobalStateChange((state, prev) => {
     // state: 变更后的状态; prev 变更前的状态
     initParentStore(state);

+ 186 - 0
src/views/factoryModel/station/components/ProduceDialog.vue

@@ -0,0 +1,186 @@
+<template>
+  <ele-modal
+    width="70vw"
+    :visible.sync="visible"
+    :close-on-click-modal="true"
+    append-to-body
+    custom-class="ele-dialog-form"
+    title="选择工艺路线"
+  >
+    <el-form label-width="120px">
+      <el-row>
+        <el-col :span="6">
+          <el-form-item label="工艺路线编码" prop="routingCode">
+            <el-input v-model="searchData.routingCode"></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="工艺路线名称" prop="routingName">
+            <el-input v-model="searchData.routingName"></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="工艺路线版本" prop="routingVersion">
+            <el-input v-model="searchData.routingVersion"></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="工序编号" prop="taskInstanceCode">
+            <el-input v-model="searchData.taskInstanceCode"></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="工序名称" prop="taskInstanceName">
+            <el-input v-model="searchData.taskInstanceName"></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="产品编码" prop="categoryCode">
+            <el-input v-model="searchData.categoryCode"></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="产品名称" prop="categoryName">
+            <el-input v-model="searchData.categoryName"></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <div class="ele-form-actions">
+            <el-button type="primary" @click="search">搜索</el-button>
+            <el-button @click="reset">重置</el-button>
+          </div>
+        </el-col>
+      </el-row>
+    </el-form>
+
+    <ele-pro-table
+      :columns="columns"
+      :datasource="datasource"
+      :selection.sync="selection"
+      ref="table"
+      height="45vh"
+      :initLoad="false"
+      row-key="id"
+    ></ele-pro-table>
+
+    <div slot="footer">
+      <el-button type="primary" @click="confirm">确定</el-button>
+      <el-button @click="cancel">返回</el-button>
+    </div>
+  </ele-modal>
+</template>
+
+<script>
+  import { getProduceList } from '@/api/factoryModel';
+  export default {
+    data () {
+      return {
+        visible: false,
+        isUpdate: false,
+        selection: [],
+        searchData: {
+          routingCode: '',
+          routingName: '',
+          routingVersion: '',
+          taskInstanceCode: '',
+          taskInstanceName: '',
+          categoryCode: '',
+          categoryName: ''
+        },
+        columns: [
+          {
+            columnKey: 'selection',
+            type: 'selection',
+            width: 45,
+            align: 'center',
+            reserveSelection: true
+          },
+          {
+            label: '工艺路线编码',
+            prop: 'routingCode'
+          },
+          {
+            label: '工艺路线名称',
+            prop: 'routingName'
+          },
+          {
+            label: '工艺路线版本',
+            prop: 'routingVersion'
+          },
+          {
+            label: '工序编号',
+            prop: 'taskInstanceCode'
+          },
+          {
+            label: '工序组名称',
+            prop: 'taskInstanceName'
+          },
+          {
+            label: '产品编码',
+            prop: 'categoryCode'
+          },
+          {
+            label: '产品名称',
+            prop: 'categoryName'
+          }
+        ],
+        memo: []
+      };
+    },
+    methods: {
+      open (memo) {
+        this.memo = memo.slice(0);
+
+        this.visible = true;
+        this.$nextTick(() => {
+          this.$refs.table.reload();
+        });
+      },
+      datasource ({ page, limit }) {
+        return getProduceList({
+          pageNum: page,
+          size: limit,
+          ...this.searchData
+        }).then((res) => {
+          if (this.memo.length) {
+            this.$nextTick(() => {
+              const items = res.list.filter((i) => {
+                const index = this.memo.findIndex((p) => p == i.id);
+                if (index > -1) {
+                  this.memo.splice(index, 1);
+                  return true;
+                }
+                return false;
+              });
+              if (items?.length) {
+                this.$refs.table.setSelectedRows(items);
+              }
+            });
+          }
+          return res;
+        });
+      },
+      cancel () {
+        this.$refs.table.clearSelection();
+        this.searchData = {};
+        this.visible = false;
+      },
+      confirm () {
+        if (!this.selection?.length) {
+          return this.$message.error('请选择数据');
+        }
+
+        this.$emit('success', this.selection);
+
+        this.cancel();
+      },
+      search () {
+        this.$refs.table.reload();
+      },
+      reset () {
+        this.searchData = {};
+        this.$refs.table.reload();
+      }
+    }
+  };
+</script>

+ 371 - 347
src/views/factoryModel/station/components/edit.vue

@@ -65,10 +65,7 @@
           </el-col>
           <el-col :span="8">
             <el-form-item label="设备名称:" prop="extInfo.assetName">
-              <el-input
-                disabled
-                v-model="form.extInfo.assetName"
-              />
+              <el-input disabled v-model="form.extInfo.assetName" />
             </el-form-item>
           </el-col>
           <el-col :span="8">
@@ -155,9 +152,10 @@
               </el-select>
             </el-form-item>
           </el-col>
-          <el-col :span="8">
-            <el-form-item label="可执行工序:" prop="extInfo.produceId">
-              <el-select
+          <el-col :span="16">
+            <el-form-item label="可执行工序:" prop="taskNames">
+              <el-input :value="form.taskNames && form.taskNames.join(',')" placeholder="请选择" @click.native="handleProduce"></el-input>
+              <!-- <el-select
                 v-model="form.extInfo.produceId"
                 placeholder="请选择"
                 style="width: 100%"
@@ -168,12 +166,12 @@
                   :label="item.name"
                   :value="item.id"
                 >
-                </el-option>
+                </el-option> -->
               </el-select>
             </el-form-item>
           </el-col>
 
-         <el-col :span="8">
+          <el-col :span="8">
             <el-form-item label="状态:" prop="enabled">
               <el-select
                 v-model="form.enabled"
@@ -200,7 +198,12 @@
                   v-model="form.extInfo.meterTime"
                   placeholder="请输入"
                 />
-                <DictSelection style="width:30%" dictName="计量单位" clearable v-model="form.extInfo.meterMeasuringUnit">
+                <DictSelection
+                  style="width: 30%"
+                  dictName="计量单位"
+                  clearable
+                  v-model="form.extInfo.meterMeasuringUnit"
+                >
                 </DictSelection>
                 <span class="s3">/</span>
                 <el-select
@@ -220,7 +223,6 @@
             </el-form-item>
           </el-col>
 
-
           <el-col :span="24">
             <el-form-item label="备注:" prop="remark">
               <el-input
@@ -234,7 +236,7 @@
           </el-col>
         </el-row>
       </el-card>
-<!--      <el-card
+      <!--      <el-card
         shadow="never"
         header="关联设备"
         body-style="padding: 22px 22px 0 22px;"
@@ -249,372 +251,394 @@
       </el-button>
     </template>
 
-     <!-- 选择设备 -->
-    <AssetSelection ref="equipmentTable" @confirm="assetConfirm"></AssetSelection>
+    <!-- 选择设备 -->
+    <AssetSelection
+      ref="equipmentTable"
+      @confirm="assetConfirm"
+    ></AssetSelection>
+    <ProduceDialog ref="produceRef"  @success="produceConfirm"/>
   </el-dialog>
 </template>
 
 <script>
-import {
-  listWorkshopByParentId,
-  saveOrUpdate_gw,
-  listFactoryLineByParentId,
-  getById
-} from '@/api/factoryModel';
-import { getUserPage } from '@/api/system/organization';
-import AssetSelection from './AssetSelection.vue';
-import producetask from '@/api/technology/production';
-import work from '@/api/technology/work';
-export default {
-  components: {
-    AssetSelection
-  },
-  props: {
-    options_groupId: {
-      type: Array,
-      default() {
-        return [];
+  import {
+    listWorkshopByParentId,
+    saveOrUpdate_gw,
+    listFactoryLineByParentId,
+    getById
+  } from '@/api/factoryModel';
+  import { getUserPage } from '@/api/system/organization';
+  import AssetSelection from './AssetSelection.vue';
+  import producetask from '@/api/technology/production';
+  import work from '@/api/technology/work';
+  import ProduceDialog from './ProduceDialog'
+  export default {
+    components: {
+      AssetSelection,
+      ProduceDialog
+    },
+    props: {
+      options_groupId: {
+        type: Array,
+        default () {
+          return [];
+        }
+      },
+      options_factory: {
+        type: Array,
+        default () {
+          return [];
+        }
       }
     },
-    options_factory: {
-      type: Array,
-      default() {
-        return [];
+    watch: {
+      options_groupId (nval) {
+        this.toTreeData(nval);
       }
-    }
-  },
-  watch: {
-    options_groupId(nval) {
-      this.toTreeData(nval);
-    }
-  },
-  data() {
-    const defaultForm = function () {
-      return {
-        code: '',
-        enabled: 1,
-        extInfo: {
-          factoryId: '', // 工厂
-          workshopId: '', // 车间
-          principalDep: '', // 负责人部门
-          meterTimeUnit: '时', // 节拍时间单位
-          meterTime: '' ,// 节拍时间
-          assetCode:'',  //设备编码
-          assetName:''   ,//设备名称
-          meterMeasuringUnit:'', // 节拍计量单位
-          workCenterId:null,  //所属工作中心
-          produceId:null      //可执行工序
-        },
-        id: '',
-        leaderId: '', // 负责人
-        name: '',
-        productionLineId: '',
-        remark: '',
-        workstationSubstanceList: []
+    },
+    data () {
+      const defaultForm = function () {
+        return {
+          code: '',
+          enabled: 1,
+          extInfo: {
+            factoryId: '', // 工厂
+            workshopId: '', // 车间
+            principalDep: '', // 负责人部门
+            meterTimeUnit: '时', // 节拍时间单位
+            meterTime: '', // 节拍时间
+            assetCode: '', //设备编码
+            assetName: '', //设备名称
+            meterMeasuringUnit: '', // 节拍计量单位
+            workCenterId: null, //所属工作中心
+            produceId: null //可执行工序
+          },
+          id: '',
+          leaderId: '', // 负责人
+          name: '',
+          productionLineId: '',
+          remark: '',
+          taskIds:[],
+          taskNames:[],
+          workstationSubstanceList: []
+        };
       };
-    };
-    return {
-      defaultForm,
-      // 表单数据
-      form: defaultForm(),
-      // 表单验证规则
-      rules: {
-        code: [{ required: true, message: '请输入', trigger: 'blur' }],
-        name: [{ required: true, message: '请输入', trigger: 'blur' }],
-        workCenterId:[{ required: true, message: '请选择', trigger: 'change' }],
-        processId:[{ required: true, message: '请选择', trigger: 'change' }],
-        'extInfo.factoryId': [
-          { required: true, message: '请输入', trigger: 'change' }
-        ],
-        'extInfo.principalDep': [
-          { required: true, message: '请输入', trigger: 'change' }
-        ],
-        'extInfo.assetCode': [
-          { required: true, message: '请选择', trigger: 'change' }
-        ],
-        'extInfo.assetName': [
-          { required: true, message: '请选择', trigger: 'change' }
-        ],
-        'extInfo.workshopId': {
-          required: true,
-          message: '请输入',
-          trigger: 'change'
-        },
-        'extInfo.workCenterId':{
-           required: true,
-           message: '请输入',
-           trigger: 'change'
-        },
-        'extInfo.produceId':{
-           required: true,
-           message: '请输入',
-           trigger: 'change'
-        },
-        productionLineId: {
-          required: true,
-          message: '请输入',
-          trigger: 'change'
-        },
-        leaderId: {
-          required: true,
-          message: '请输入',
-          trigger: 'change'
-        }
-      },
-      visible: false,
-      type: '', // add/edit
-      loading: false,
-      options: {
-        leaderId: [],
-        workshopId: [],
-        workCenterList:[],
-        produceList:[],
-        enabled: [
-          {
-            label: '生效',
-            value: 1
+      return {
+        defaultForm,
+        // 表单数据
+        form: defaultForm(),
+        // 表单验证规则
+        rules: {
+          code: [{ required: true, message: '请输入', trigger: 'blur' }],
+          name: [{ required: true, message: '请输入', trigger: 'blur' }],
+          workCenterId: [
+            { required: true, message: '请选择', trigger: 'change' }
+          ],
+          processId: [{ required: true, message: '请选择', trigger: 'change' }],
+          'extInfo.factoryId': [
+            { required: true, message: '请输入', trigger: 'change' }
+          ],
+          'extInfo.principalDep': [
+            { required: true, message: '请输入', trigger: 'change' }
+          ],
+          'extInfo.assetCode': [
+            { required: true, message: '请选择', trigger: 'change' }
+          ],
+          'extInfo.assetName': [
+            { required: true, message: '请选择', trigger: 'change' }
+          ],
+          'extInfo.workshopId': {
+            required: true,
+            message: '请输入',
+            trigger: 'change'
           },
-          {
-            label: '未生效',
-            value: 0
-          }
-        ],
-        meterTimeUnit: [
-          {
-            value: '时',
-            label: '时'
+          'extInfo.workCenterId': {
+            required: true,
+            message: '请输入',
+            trigger: 'change'
           },
-          {
-            value: '分',
-            label: '分'
+          'extInfo.taskNames': {
+            required: true,
+            message: '请输入',
+            trigger: 'change'
           },
-          {
-            value: '秒',
-            label: '秒'
+          productionLineId: {
+            required: true,
+            message: '请输入',
+            trigger: 'change'
           },
-          {
-            value: '日',
-            label: '日'
+          leaderId: {
+            required: true,
+            message: '请输入',
+            trigger: 'change'
           }
-        ],
-        productionLineId: []
-      }
-    };
-  },
-  computed: {
-    title() {
-      switch (this.type) {
-        case 'add':
-          return '新增工位';
-          break;
-        case 'edit':
-          return '编辑工位';
-          break;
-        default:
-          break;
+        },
+        visible: false,
+        type: '', // add/edit
+        loading: false,
+        options: {
+          leaderId: [],
+          workshopId: [],
+          workCenterList: [],
+          produceList: [],
+          enabled: [
+            {
+              label: '生效',
+              value: 1
+            },
+            {
+              label: '未生效',
+              value: 0
+            }
+          ],
+          meterTimeUnit: [
+            {
+              value: '时',
+              label: '时'
+            },
+            {
+              value: '分',
+              label: '分'
+            },
+            {
+              value: '秒',
+              label: '秒'
+            },
+            {
+              value: '日',
+              label: '日'
+            }
+          ],
+          productionLineId: []
+        }
+      };
+    },
+    computed: {
+      title () {
+        switch (this.type) {
+          case 'add':
+            return '新增工位';
+          case 'edit':
+            return '编辑工位';
+          default:
+            break;
+        }
       }
-    }
-  },
-  methods: {
-    chooseAsset(){
-        this.$refs.equipmentTable.open(this.form.extInfo)
     },
+    methods: {
+      chooseAsset () {
+        this.$refs.equipmentTable.open(this.form.extInfo);
+      },
+      // 选择可执行工序
+      handleProduce(){
+         this.$refs.produceRef.open(this.form.taskIds)
+      },
+      produceConfirm(list){
+         this.form.taskIds = list.map(i => i.id)
+         this.form.taskNames = list.map(i => i.taskInstanceName)
 
-    assetConfirm(data){
-      this.form.extInfo.assetCode = data.code
-      this.form.extInfo.assetName = data.name
-      this.form.extInfo.assetId = data.id
-    },
+         console.log(list);
+         console.log(this.form);
+      },
+
+      assetConfirm (data) {
+        this.form.extInfo.assetCode = data.code;
+        this.form.extInfo.assetName = data.name;
+        this.form.extInfo.assetId = data.id;
+      },
 
-    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];
+      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];
+              }
             }
           }
+          this.getData(row.id);
+          // 请求下拉数据
+          if (this.form.extInfo.factoryId) {
+            this.getListWorkshopByParentId();
+          }
+          if (this.form.extInfo.workshopId) {
+            this.getlistFactoryLineByParentId();
+          }
+          if (this.form.extInfo.principalDep) {
+            this.getUserPage();
+          }
         }
-        this.getData(row.id);
-        // 请求下拉数据
-        if (this.form.extInfo.factoryId) {
-          this.getListWorkshopByParentId();
-        }
-        if (this.form.extInfo.workshopId) {
-          this.getlistFactoryLineByParentId();
-        }
-        if (this.form.extInfo.principalDep) {
-          this.getUserPage();
-        }
-      }
-      this.getListWorkCenter()
-      this.getListProduce()
-    },
-    /* 保存编辑 */
-    save() {
-      this.$refs.form.validate((valid) => {
-        if (!valid) {
-          return false;
-        }
-        this.loading = true;
+        this.getListWorkCenter();
+        this.getListProduce();
+      },
+      /* 保存编辑 */
+      save () {
+        this.$refs.form.validate((valid) => {
+          if (!valid) {
+            return false;
+          }
+          this.loading = true;
 
-        if (this.type == 'add') {
-          delete this.form.id;
-        }
-        // this.form.workstationSubstanceList =
-        //   this.$refs.equipmentTable.datasource.map((n) => {
-        //     return {
-        //       type: 1,
-        //       substanceId: n.id
-        //     };
-        //   });
-        this.form.workstationSubstanceList = [
-          {
-             type: 1,
-             substanceId: this.form.extInfo.assetId
+          if (this.type == 'add') {
+            delete this.form.id;
           }
-        ]
-        saveOrUpdate_gw(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.loading = false;
-      this.visible = false;
-    },
-    // 格式化公司数据
-    toTreeData(val) {
-      this.options.principalDep = this.$util.toTreeData({
-        data: val,
-        idField: 'id',
-        parentIdField: 'parentId'
-      });
-    },
+          // this.form.workstationSubstanceList =
+          //   this.$refs.equipmentTable.datasource.map((n) => {
+          //     return {
+          //       type: 1,
+          //       substanceId: n.id
+          //     };
+          //   });
+          this.form.workstationSubstanceList = [
+            {
+              type: 1,
+              substanceId: this.form.extInfo.assetId
+            }
+          ];
+          saveOrUpdate_gw(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.loading = false;
+        this.visible = false;
+      },
+      // 格式化公司数据
+      toTreeData (val) {
+        this.options.principalDep = this.$util.toTreeData({
+          data: val,
+          idField: 'id',
+          parentIdField: 'parentId'
+        });
+      },
 
-    // 获取工作中心
-    getListWorkCenter(){
-        work.list({ pageNum: 1,  size: -1 }).then(res=>{
-            this.options.workCenterList = res.list;
-        })
-    },
+      // 获取工作中心
+      getListWorkCenter () {
+        work.list({ pageNum: 1, size: -1 }).then((res) => {
+          this.options.workCenterList = res.list;
+        });
+      },
 
-    // 获取工序
-    getListProduce(){
-        producetask.list({ pageNum: 1,  size: -1 }).then(res=>{
-            this.options.produceList = res.list;
-        })
-    },
+      // 获取工序
+      getListProduce () {
+        producetask.list({ pageNum: 1, size: -1 }).then((res) => {
+          this.options.produceList = res.list;
+        });
+      },
 
-    // 获取车间
-    getListWorkshopByParentId() {
-      listWorkshopByParentId(this.form.extInfo.factoryId).then((res) => {
-        this.options.workshopId = res;
-      });
-    },
-    // 获取产线
-    getlistFactoryLineByParentId() {
-      console.log(this.form.extInfo.workshopId);
-      listFactoryLineByParentId(this.form.extInfo.workshopId).then((res) => {
-        console.log(res);
-        this.options.productionLineId = res;
-      });
-    },
-    // 获取人员
-    getUserPage() {
-      let par = {
-        groupId: this.form.extInfo.principalDep,
-        size: 999
-      };
-      getUserPage(par).then((res) => {
-        this.options.leaderId = res.list;
-      });
-    },
-    // 选择工厂
-    change_factoryId() {
-      this.form.extInfo.workshopId = '';
-      this.form.leaderId = '';
-      this.options.workshopId = [];
-      this.options.leaderId = [];
-      this.getListWorkshopByParentId();
-    },
-    // 选择负责人部门
-    change_principalDep() {
-      this.form.leaderId = '';
-      this.getUserPage();
-    },
-    // 选择车间
-    change_workshop() {
-      this.form.leaderId = '';
-      this.options.leaderId = [];
-      this.getlistFactoryLineByParentId();
-    },
-    // 选择产线
-    change_productionLineId() {},
-    // 请求详情
-    getData(id) {
-      getById(id).then((res) => {
-        if (
-          res.workstationSubstanceList &&
-          res.workstationSubstanceList.length > 0
-        ) {
-          let list = res.workstationSubstanceList.map((n) => {
-            return n.substance;
-          });
-          if (list.length > 0) {
-            this.$refs.equipmentTable.datasource = list;
+      // 获取车间
+      getListWorkshopByParentId () {
+        listWorkshopByParentId(this.form.extInfo.factoryId).then((res) => {
+          this.options.workshopId = res;
+        });
+      },
+      // 获取产线
+      getlistFactoryLineByParentId () {
+        console.log(this.form.extInfo.workshopId);
+        listFactoryLineByParentId(this.form.extInfo.workshopId).then((res) => {
+          console.log(res);
+          this.options.productionLineId = res;
+        });
+      },
+      // 获取人员
+      getUserPage () {
+        let par = {
+          groupId: this.form.extInfo.principalDep,
+          size: 999
+        };
+        getUserPage(par).then((res) => {
+          this.options.leaderId = res.list;
+        });
+      },
+      // 选择工厂
+      change_factoryId () {
+        this.form.extInfo.workshopId = '';
+        this.form.leaderId = '';
+        this.options.workshopId = [];
+        this.options.leaderId = [];
+        this.getListWorkshopByParentId();
+      },
+      // 选择负责人部门
+      change_principalDep () {
+        this.form.leaderId = '';
+        this.getUserPage();
+      },
+      // 选择车间
+      change_workshop () {
+        this.form.leaderId = '';
+        this.options.leaderId = [];
+        this.getlistFactoryLineByParentId();
+      },
+      // 选择产线
+      change_productionLineId () {},
+      // 请求详情
+      getData (id) {
+        getById(id).then((res) => {
+          if (
+            res.workstationSubstanceList &&
+            res.workstationSubstanceList.length > 0
+          ) {
+            let list = res.workstationSubstanceList.map((n) => {
+              return n.substance;
+            });
+            if (list.length > 0) {
+              this.$refs.equipmentTable.datasource = list;
+            }
           }
-        }
-      });
+          this.form = Object.assign({}, this.form, res)
+
+          if(res.taskInstanceList?.length){
+            this.form.taskNames = res.taskInstanceList.map(i => i.name)
+          }
+        });
+      }
     }
-  }
-};
+  };
 </script>
 <style lang="scss" scoped>
-.location-warp {
-  display: flex;
-  .detail {
-    margin-left: 10px;
-  }
-}
-.workMeter-warp {
-  .s1 {
-    width: 30%;
-    margin-right: 10px;
-  }
-  .s2 {
-    width: 20%;
-    margin-left: 10px;
+  .location-warp {
+    display: flex;
+    .detail {
+      margin-left: 10px;
+    }
   }
-  .s3 {
-    margin-left: 10px;
+  .workMeter-warp {
+    .s1 {
+      width: 30%;
+      margin-right: 10px;
+    }
+    .s2 {
+      width: 20%;
+      margin-left: 10px;
+    }
+    .s3 {
+      margin-left: 10px;
+    }
   }
-}
-:deep(
-    .el-dialog:not(.ele-dialog-form)
+  :deep(.el-dialog:not(.ele-dialog-form)
       .el-dialog__body
       .el-form
-      .el-form-item:last-child
-  ) {
-  margin-bottom: 22px;
-}
+      .el-form-item:last-child) {
+    margin-bottom: 22px;
+  }
 </style>

+ 37 - 28
src/views/material/manage/components/index-data.vue

@@ -15,22 +15,22 @@
     >
       <!-- 表头工具栏 -->
       <template v-slot:toolbar>
-          <el-button
-            size="small"
-            type="primary"
-            icon="el-icon-plus"
-            class="ele-btn-icon"
-            @click="openEdit({},2)"
-          >
-            新建物料
-          </el-button>
+        <el-button
+          size="small"
+          type="primary"
+          icon="el-icon-plus"
+          class="ele-btn-icon"
+          @click="openEdit({}, 2)"
+        >
+          新建物料
+        </el-button>
       </template>
       <template v-slot:action="{ row }">
         <el-link
           type="primary"
           :underline="false"
           icon="el-icon-copy-document"
-          @click="openEdit(row,1)"
+          @click="openEdit(row, 1)"
         >
           复制
         </el-link>
@@ -38,7 +38,7 @@
           type="primary"
           :underline="false"
           icon="el-icon-edit"
-          @click="openEdit(row,0)"
+          @click="openEdit(row, 0)"
         >
           修改
         </el-link>
@@ -56,30 +56,30 @@
       </template>
     </ele-pro-table>
     <!-- 编辑弹窗 -->
-<!--    <dict-edit :visible.sync="showEdit" :id="id" @done="reload" /> -->
+    <!--    <dict-edit :visible.sync="showEdit" :id="id" @done="reload" /> -->
   </div>
 </template>
 
 <script>
-  import { getMaterialList , removeMaterial } from '@/api/material/manage.js';
+  import { getMaterialList, removeMaterial } from '@/api/material/manage.js';
   export default {
-    components: { },
+    components: {},
     props: {
       // 物料组id
       currentId: [Number, String],
-      data:Object
+      data: Object
     },
-    data() {
+    data () {
       return {
         // 表格列配置
         columns: [
           {
             columnKey: 'index',
             type: 'index',
-            width: 45,
+            width: 55,
             align: 'center',
             showOverflowTooltip: true,
-            label:'序号'
+            label: '序号'
           },
           {
             prop: 'code',
@@ -143,7 +143,7 @@
             resizable: false,
             slot: 'action',
             showOverflowTooltip: true,
-            fixed:'right'
+            fixed: 'right'
           }
         ],
         types: {
@@ -160,26 +160,35 @@
 
     methods: {
       /* 表格数据源 */
-      datasource({ page, limit, where, order }) {
-        return getMaterialList({ pageNum: page, size: limit, ...where , categoryLevelGroupId:this.currentId });
+      datasource ({ page, limit, where, order }) {
+        return getMaterialList({
+          pageNum: page,
+          size: limit,
+          ...where,
+          categoryLevelGroupId: this.currentId
+        });
       },
       /* 刷新表格 */
-      reload(where) {
-        this.$refs.table.reload({ page: 1, where: where ,  categoryLevelGroupId:this.currentId  });
+      reload (where) {
+        this.$refs.table.reload({
+          page: 1,
+          where: where,
+          categoryLevelGroupId: this.currentId
+        });
       },
       /* 显示编辑 */
-      openEdit(row,status) {
+      openEdit (row, status) {
         this.$router.push({
           path: '/material/manage/manageMaterial',
           query: {
             chooseTab: JSON.stringify(this.data),
-            id: row.id?row.id:null,
-            status:status
+            id: row.id ? row.id : null,
+            status: status
           }
         });
       },
       /* 删除 */
-      remove(row) {
+      remove (row) {
         const loading = this.$loading({ lock: true });
         removeMaterial(row.id)
           .then((msg) => {
@@ -195,7 +204,7 @@
     },
     watch: {
       // 监听物料组id变化
-      currentId() {
+      currentId () {
         this.reload();
       }
     }

+ 24 - 16
src/views/material/manage/index.vue

@@ -2,7 +2,7 @@
   <div class="ele-body">
     <el-card shadow="never">
       <IndexSearch @search="reload" />
-<!--      <div style="margin: 5px 0; padding-left: 262px">
+      <!--      <div style="margin: 5px 0; padding-left: 262px">
         <el-button
           size="small"
           type="primary"
@@ -29,18 +29,24 @@
           :current.sync="current"
           highlight-current-row
           class="dict-table"
+          row-key="id"
           tool-class="ele-toolbar-actions"
           @done="done"
         >
           <!-- 表头工具栏 -->
-<!--          <template v-slot:toolbar>
+          <!--          <template v-slot:toolbar>
 
           </template> -->
         </ele-pro-table>
 
         <template v-slot:content>
           <!-- 物料列表 -->
-          <IndexData ref="listData" v-if="current" :current-id="current.id" :data="current"/>
+          <IndexData
+            ref="listData"
+            v-if="current"
+            :current-id="current.id"
+            :data="current"
+          />
         </template>
       </ele-split-layout>
     </el-card>
@@ -54,8 +60,8 @@
   import { getGroupPage } from '@/api/material/list';
   export default {
     name: 'SystemDictionary',
-    components: { IndexData , IndexSearch },
-    data() {
+    components: { IndexData, IndexSearch },
+    data () {
       return {
         // 表格列配置
         columns: [
@@ -77,31 +83,33 @@
         // 是否显示编辑弹窗
         showEdit: false,
         // 编辑回显数据
-        editData: null,
+        editData: null
       };
     },
 
-    created() {
-    },
+    created () {},
 
     methods: {
       /* 表格数据源 */
-      datasource() {
-        return getGroupPage({pageNum:1,size:-1});
+      datasource () {
+        return getGroupPage({ pageNum: 1, size: -1 });
       },
       /* 表格渲染完成回调 */
-      done(res) {
+      done (res) {
+        console.log(this.current, 'this.current', res);
         if (res.data?.length) {
-          this.$refs.table.setCurrentRow(res.data[0]);
+          let currentRow = null;
+          if (this.current) {
+            currentRow = res.data.find((item) => item.id == this.current.id);
+          }
+          this.$refs.table.setCurrentRow(currentRow || res.data[0]);
         }
       },
       /* 刷新表格 */
-      reload(where) {
+      reload (where) {
         this.$refs.table.reload();
         this.$refs.listData.reload(where);
-      },
-
-
+      }
     }
   };
 </script>