quwangxin 2 лет назад
Родитель
Сommit
13b4bab0ca

+ 12 - 0
src/api/mainData/index.js

@@ -0,0 +1,12 @@
+import request from '@/utils/request';
+
+/**
+ * 分页查询生产版本
+ */
+export async function versionPage (params) {
+  const res = await request.get(`/main/produceversion/page`, { params });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 20 - 0
src/api/materialPlan/index.js

@@ -20,3 +20,23 @@ export async function save (data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+/**
+ * 修改
+ */
+export async function update (data) {
+  const res = await request.put('/aps/batchingplan/update', data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+/**
+ * 修改
+ */
+export async function del (data) {
+  const res = await request.delete('/aps/batchingplan/delete', data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 11 - 2
src/components/CommomSelect/classes-select.vue

@@ -19,6 +19,7 @@
 
 <script>
   import { getteamtime } from '@/api/workforceManagement/classes';
+
   export default {
     model: {
       prop: 'value',
@@ -36,10 +37,13 @@
     },
     data () {
       return {
-        dictList: []
+        selectName: 'classes'
       };
     },
     computed: {
+      dictList () {
+        return this.$store.state.selectCache[this.selectName] || [];
+      },
       selectVal: {
         set (val) {
           this.$emit(
@@ -61,11 +65,16 @@
     },
     methods: {
       async getList () {
+        if (this.dictList.length) return;
         const res = await getteamtime({
           pageNum: 1,
           size: -1
         });
-        this.dictList = res.list;
+
+        this.$store.commit('selectCache/ADD_SELECT', {
+          name: this.selectName,
+          dict: res.list
+        });
       }
     }
   };

+ 146 - 108
src/components/CreatePlan/ChooseMaterial.vue

@@ -10,45 +10,56 @@
   >
     <div>
       <el-row>
-		<el-col :span="24" class="topsearch">
-			<el-form >
-			  <el-row>
-          <el-col :span="6">
-            <el-input
-              v-model="searchKey"
-              placeholder="输入设备编码或名称"
-              size="small"
-            ></el-input>
-          </el-col>
-          <el-col :span="6" style="margin-left:10px">
-             <el-button type="primary" size="small" @click="searchByKeyWords">搜索</el-button>
-             <el-button size="small" @click="reset">重置</el-button>
-          </el-col>
-			  </el-row>
-			</el-form>
-		</el-col>
+        <el-col :span="24" class="topsearch">
+          <el-form>
+            <el-row>
+              <el-col :span="6">
+                <el-input
+                  v-model.trim="searchKey"
+                  placeholder="输入设备编码或名称"
+                  size="small"
+                ></el-input>
+              </el-col>
+              <el-col :span="6" style="margin-left: 10px">
+                <el-button type="primary" size="small" @click="searchByKeyWords"
+                  >搜索</el-button
+                >
+                <el-button size="small" @click="reset">重置</el-button>
+              </el-col>
+            </el-row>
+          </el-form>
+        </el-col>
         <el-col :span="6" class="tree_col">
           <AssetTree
             @handleNodeClick="handleNodeClick"
             @setRootId="setRootId"
-            :type="'5'"
-            :paramsType="'type'"
+            id="1"
             ref="treeList"
           />
         </el-col>
         <el-col :span="18" class="table_col">
           <el-table
             :data="tableData"
+            ref="tableRef"
             height="450"
             @row-click="single"
           >
-            <el-table-column label="物品编码" prop="code" width="200"></el-table-column>
+            <el-table-column
+              label="物品编码"
+              prop="code"
+              width="200"
+            ></el-table-column>
             <el-table-column label="物品名称" prop="name"></el-table-column>
-            <el-table-column label="牌号" prop="classificationUrl"></el-table-column>
+            <el-table-column label="牌号" prop="brandNum"></el-table-column>
             <el-table-column label="选择" align="center">
-               <template slot-scope="scope">
-            	 <el-radio class="radio" v-model="radio" :label="scope.row.id"><i></i></el-radio>
-               </template>
+              <template slot-scope="scope">
+                <el-radio
+                  class="radio"
+                  v-model="selectedRow.id"
+                  :label="scope.row.id"
+                  ><i></i
+                ></el-radio>
+              </template>
             </el-table-column>
           </el-table>
           <div class="pagination">
@@ -58,7 +69,7 @@
               :total="total"
               :page-sizes="[5, 10, 20, 50, 100]"
               :page-size="pagination.size"
-              :current-page.sync="pagination.page"
+              :current-page.sync="pagination.pageNum"
               @current-change="handleCurrent"
               @size-change="handleSize"
             >
@@ -76,95 +87,122 @@
 
 <script>
   import AssetTree from '@/components/AssetTree';
-export default {
-  components: {
-    AssetTree
-  },
-  data () {
-    return {
-      materialdialog: false,
-      tableData: [
-		  {id:1,name:'122',model:'型号1'},
-		  {id:2,name:'222',model:'型号2'}
-	  ],
-      pagination: {
-        page: 1,
-        size: 10
+  import { getList } from '@/api/classifyManage/itemInformation';
+  export default {
+    components: {
+      AssetTree
+    },
+    data () {
+      return {
+        materialdialog: false,
+        tableData: [],
+        pagination: {
+          pageNum: 1,
+          size: 10
+        },
+        total: 0,
+        searchKey: null,
+        current: null,
+        rootId: null,
+        selectedRow: {},
+        radio: '',
+        memoId: ''
+      };
+    },
+    methods: {
+      open (categoryId) {
+        this.memoId = categoryId;
+        this.materialdialog = true;
+      },
+      handleNodeClick (info) {
+        this.current = info;
+        this._getList();
+      },
+      // 获取根节点id
+      setRootId (id) {
+        this.rootId = id;
+      },
+      handleClose () {
+        this.materialdialog = false;
+        this.selectedRow = {};
       },
-	  total: 0,
-	    searchKey:null,
-	    current:null,
-	    rootId:null,
-		radio: '',
-    }
-  },
-  watch: {
 
-  },
-  methods: {
-	open(){
-		this.materialdialog = true
-	},
-	handleNodeClick (info) {
-	  this.current = info
-	},
-	// 获取根节点id
-	setRootId(id){
-	  this.rootId = id
-	},
-    handleClose () {
-      this.materialdialog = false
-	  this.radio = ''
-    },
+      handleCurrent (page) {
+        this.pagination.pageNum = page;
+        this._getList();
+      },
+      handleSize (size) {
+        this.pagination.pageNum = 1;
+        this.pagination.size = size;
+        this._getList();
+      },
+      async _getList () {
+        const res = await getList({
+          ...this.pagination,
+          searchKey: this.searchKey,
+          categoryLevelId: this.current.id
+        });
+        this.total = res.count;
+        this.tableData = res.list;
 
-    handleCurrent (page) {
-      this.pagination.page = page
-    },
-    handleSize (size) {
-      this.pagination.page = 1
-      this.pagination.size = size
-    },
-    // 弹窗 - 按关键字搜索
-    searchByKeyWords () {
+        if (!this.current.id) {
+          this.$nextTick(() => {
+            this.$refs.tableRef.setCurrentRow(
+              this.tableData.find((i) => i.id == this.memoId)
+            );
+          });
+        }
+      },
+      // 弹窗 - 按关键字搜索
+      searchByKeyWords () {
+        this.pagination.pageNum = 1;
+        this._getList();
+      },
+      // 重置
+      reset () {
+        this.searchKey = '';
+        this.pagination.pageNum = 1;
+        this._getList();
+      },
+      // 单击获取id
+      single (row) {
+        this.selectedRow = row;
+      },
+      selected () {
+        if (!this.selectedRow.id) {
+          return this.$message.error('请选择物料!');
+        }
 
-    },
-    // 重置
-    reset(){
-    },
-	// 单击获取id
-	single (row) {
-	     this.radio = row.id;
-	},
-	selected(){
-		
-	}
-  }
-}
+        this.$emit('success', this.selectedRow);
+        this.handleClose();
+      }
+    }
+  };
 </script>
 
 <style lang="scss" scoped>
-.tree_col {
-  border: 1px solid #eee;
-  padding: 10px 0;
-  box-sizing: border-box;
-  height: 500px;
-  overflow: auto;
-}
-.table_col {
-  padding-left: 10px;
-  ::v-deep .el-table th.el-table__cell {
-    background: #f2f2f2;
+  .tree_col {
+    border: 1px solid #eee;
+    padding: 10px 0;
+    box-sizing: border-box;
+    height: 500px;
+    overflow: auto;
+  }
+  .table_col {
+    padding-left: 10px;
+    ::v-deep .el-table th.el-table__cell {
+      background: #f2f2f2;
+    }
+  }
+  .pagination {
+    text-align: right;
+    padding: 10px 0;
+  }
+  .btns {
+    text-align: center;
+    padding: 10px 0;
+  }
+  .topsearch {
+    margin-bottom: 15px;
   }
-}
-.pagination {
-  text-align: right;
-  padding: 10px 0;
-}
-.btns {
-  text-align: center;
-  padding: 10px 0;
-}
-.topsearch{
-	margin-bottom:15px;
-}
 </style>

+ 87 - 74
src/components/CreatePlan/ProductionVersion.vue

@@ -5,32 +5,48 @@
     width="75vw"
     append-to-body
   >
-	<el-table
-	  :data="tableData"
-	  border
-	  ref="tableData"
-	  @row-click="single"
-	>
-	  <el-table-column label="生产版本" align="center" prop="produceVersionName">
-	  </el-table-column>
-	  <el-table-column label="未完成工单数量" align="center" prop="incompleteOrderNum">
-	  </el-table-column>  
-	  <el-table-column label="未成型数量" align="center" prop="incompleteFormingNum">
-	  </el-table-column>
-	  <el-table-column label="预计完成时间" align="center" prop="planCompleteDate">
-	  </el-table-column>
-	  <el-table-column label="标准产能" align="center" prop="model">
-	  </el-table-column>
-	  <el-table-column label="原料库存" align="center" prop="materialInventory">
-	  </el-table-column>
-	  <el-table-column label="改型仓" align="center" prop="model">
-	  </el-table-column>
-	  <el-table-column label="选择" align="center">
-		   <template slot-scope="scope">
-			 <el-radio class="radio" v-model="radio" :label="scope.row.produceVersionId"><i></i></el-radio>
-		   </template>
-	  </el-table-column>
-	</el-table>
+    <el-table :data="tableData" border ref="tableData" @row-click="single">
+      <el-table-column
+        label="生产版本"
+        align="center"
+        prop="produceVersionName"
+      >
+      </el-table-column>
+      <el-table-column
+        label="未完成工单数量"
+        align="center"
+        prop="incompleteOrderNum"
+      >
+      </el-table-column>
+      <el-table-column
+        label="未成型数量"
+        align="center"
+        prop="incompleteFormingNum"
+      >
+      </el-table-column>
+      <el-table-column
+        label="预计完成时间"
+        align="center"
+        prop="planCompleteDate"
+      >
+      </el-table-column>
+      <el-table-column label="标准产能" align="center" prop="model">
+      </el-table-column>
+      <el-table-column label="原料库存" align="center" prop="materialInventory">
+      </el-table-column>
+      <el-table-column label="改型仓" align="center" prop="model">
+      </el-table-column>
+      <el-table-column label="选择" align="center">
+        <template slot-scope="scope">
+          <el-radio
+            class="radio"
+            v-model="radio"
+            :label="scope.row.produceVersionId"
+            ><i></i
+          ></el-radio>
+        </template>
+      </el-table-column>
+    </el-table>
     <template v-slot:footer>
       <el-button @click="cancel">取消</el-button>
       <el-button type="primary" @click="save" :loading="loading">
@@ -41,65 +57,62 @@
 </template>
 
 <script>
-	import { getProductVersion  } from '@/api/saleOrder';
-export default {
-	props: {
-		productCode:String
-	},
-    data() {
+  import { getProductVersion } from '@/api/saleOrder';
+  export default {
+    props: {
+      productCode: String
+    },
+    data () {
       return {
         visible: false,
-		tableData:[],
-		loading:false,
-		radio: '',
-		current:null
+        tableData: [],
+        loading: false,
+        radio: '',
+        current: null
       };
     },
-    computed: {
-    },
-    created(){
-    },
+    computed: {},
+    created () {},
     methods: {
-	  open () {
-	    this.visible = true;
-		this.getPageList()
-	  },
-	  getPageList(){
-		  getProductVersion(this.productCode).then(res=>{
-			  this.tableData = res
-		  })
-	  },
+      open () {
+        this.visible = true;
+        this.getPageList();
+      },
+      getPageList () {
+        getProductVersion(this.productCode).then((res) => {
+          this.tableData = res;
+        });
+      },
       cancel () {
         this.visible = false;
-	    this.radio = ''
-		this.current = null
+        this.radio = '';
+        this.current = null;
+      },
+      // 单击获取id
+      single (row) {
+        this.current = row;
+        this.radio = row.produceVersionId;
       },
-	  // 单击获取id
-	  single (row) {
-		  this.current = row
-	       this.radio = row.produceVersionId;
-	  },
-	  /* 保存编辑 */
-	  save() {
-	  	 this.visible = false;
-		 this.$emit('confirm',this.current)
-	  },
-	  
+      /* 保存编辑 */
+      save () {
+        this.visible = false;
+        this.$emit('confirm', this.current);
+      }
     }
   };
 </script>
 <style lang="scss" scoped>
-  .basic-details-title{
-	  margin:10px 0
+  .basic-details-title {
+    margin: 10px 0;
   }
-  .add-product{
-	  width:100%;
-	  display:flex;
-	  align-items:center;
-	  justify-content:flex-end;
-	  font-size:30px;
-	  color:#1890ff;
-	  margin:10px 0;
-	  cursor: pointer;
+  .add-product {
+    width: 100%;
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+    font-size: 30px;
+    color: #1890ff;
+    margin: 10px 0;
+    cursor: pointer;
   }
-</style>
+</style>

+ 2 - 0
src/store/index.js

@@ -6,6 +6,7 @@ import Vuex from 'vuex';
 import getters from './getters';
 import dict from './modules/dict';
 import user from './modules/user';
+import selectCache from './modules/selectCache';
 import theme from './modules/theme';
 import createPersistedState from 'vuex-persistedstate';
 
@@ -20,6 +21,7 @@ export default new Vuex.Store({
   modules: {
     dict,
     user,
+    selectCache,
     theme
   },
   getters,

+ 18 - 0
src/store/modules/selectCache.js

@@ -0,0 +1,18 @@
+// 公共选择组件数据缓存
+import Vue from 'vue';
+const state = {};
+
+const mutations = {
+  ADD_SELECT: (state, { name, dict }) => {
+    Vue.set(state, name, dict);
+  }
+};
+
+const actions = {};
+
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions
+};

+ 125 - 0
src/views/materialPlan/components/ProductionVersion.vue

@@ -0,0 +1,125 @@
+<template>
+  <ele-modal
+    :visible.sync="visible"
+    title="选择生产版本"
+    width="75vw"
+    append-to-body
+  >
+    <ele-pro-table
+      ref="table"
+      :columns="columns"
+      :datasource="datasource"
+      :toolbar="false"
+      highlight-current-row
+      :current.async="current"
+    >
+      <template v-slot:action="row">
+        <el-radio class="radio" v-model="current.id" :label="row.id"
+          ><i></i
+        ></el-radio>
+      </template>
+    </ele-pro-table>
+    <template v-slot:footer>
+      <el-button @click="cancel">取消</el-button>
+      <el-button type="primary" @click="save" :loading="loading">
+        确定
+      </el-button>
+    </template>
+  </ele-modal>
+</template>
+
+<script>
+  import { versionPage } from '@/api/mainData';
+  export default {
+    props: {
+      productCode: String
+    },
+    data () {
+      return {
+        visible: false,
+        loading: false,
+        radio: '',
+        current: {},
+        columns: [
+          {
+            type: 'index',
+            label: '序号'
+          },
+          {
+            label: '生产版本',
+            prop: 'produceVersionName'
+          },
+          {
+            label: '未完成工单数量',
+            prop: 'produceVersionName'
+          },
+          {
+            label: '未完成重量',
+            prop: 'produceVersionName'
+          },
+          {
+            label: '预计完成时间',
+            prop: 'produceVersionName'
+          },
+          {
+            label: '标准产能',
+            prop: 'produceVersionName'
+          },
+          {
+            label: '原料1库存',
+            prop: 'produceVersionName'
+          },
+          {
+            label: '原料2库存',
+            prop: 'produceVersionName'
+          },
+          {
+            label: '原料3库存',
+            prop: 'produceVersionName'
+          },
+          {
+            label: '选择',
+            slot: 'action',
+            action: 'action'
+          }
+        ]
+      };
+    },
+    computed: {},
+    created () {},
+    methods: {
+      open () {
+        this.visible = true;
+      },
+      /* 表格数据源 */
+      datasource ({ page, limit, where }) {
+        return versionPage({ pageNum: page, size: limit, ...where });
+      },
+      cancel () {
+        this.visible = false;
+        this.radio = '';
+        this.current = {};
+      },
+      /* 保存编辑 */
+      save () {
+        this.visible = false;
+        this.$emit('confirm', this.current);
+      }
+    }
+  };
+</script>
+<style lang="scss" scoped>
+  .basic-details-title {
+    margin: 10px 0;
+  }
+  .add-product {
+    width: 100%;
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+    font-size: 30px;
+    color: #1890ff;
+    margin: 10px 0;
+    cursor: pointer;
+  }
+</style>

+ 41 - 13
src/views/materialPlan/components/materialPlan-search.vue

@@ -14,18 +14,22 @@
       </el-col>
       <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
         <el-form-item label="物料编码:">
-          <el-input clearable v-model="where.code" placeholder="请输入" />
+          <el-input
+            clearable
+            v-model="where.materialCode"
+            placeholder="请输入"
+          />
         </el-form-item>
       </el-col>
       <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
         <el-form-item label="牌号:" label-width="80px">
-          <el-input clearable v-model="where.code" placeholder="请输入" />
+          <el-input clearable v-model="where.brandNo" placeholder="请输入" />
         </el-form-item>
       </el-col>
       <el-col v-bind="styleResponsive ? { lg: 9, md: 12 } : { span: 9 }">
         <el-form-item label="要求交付日期:" label-width="100px">
           <el-date-picker
-            v-model="where.time"
+            v-model="where.deliveryTime"
             type="daterange"
             range-separator="至"
             start-placeholder="开始日期"
@@ -38,13 +42,25 @@
       </el-col>
       <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
         <el-form-item label="计划状态:" label-width="80px">
-          <el-input clearable v-model="where.code" placeholder="请输入" />
+          <el-select
+            clearable
+            v-model="where.statusList"
+            placeholder="请选择"
+            class="w100"
+          >
+            <el-option
+              v-for="item in statusOpt[activeName]"
+              :label="item.label"
+              :value="item.value"
+              :key="item.value"
+            ></el-option>
+          </el-select>
         </el-form-item>
       </el-col>
       <el-col v-bind="styleResponsive ? { lg: 7, md: 12 } : { span: 7 }">
         <el-form-item label="创建时间:">
           <el-date-picker
-            v-model="where.time"
+            v-model="where.createTime"
             type="daterange"
             range-separator="至"
             start-placeholder="开始日期"
@@ -55,10 +71,13 @@
           </el-date-picker>
         </el-form-item>
       </el-col>
-      <el-col v-bind="styleResponsive ? { lg: 7, md: 12 } : { span: 7 }">
+      <el-col
+        v-bind="styleResponsive ? { lg: 7, md: 12 } : { span: 7 }"
+        v-if="activeName == 'second'"
+      >
         <el-form-item label="发布时间:">
           <el-date-picker
-            v-model="where.time"
+            v-model="where.releaseTime"
             type="daterange"
             range-separator="至"
             start-placeholder="开始日期"
@@ -90,13 +109,17 @@
 
 <script>
   export default {
+    props: ['activeName', 'statusOpt', 'planType'],
     data () {
       // 默认表单数据
       const defaultWhere = {
-        staus: '',
+        materialCode: '',
+        brandNo: '',
+        statusList: '',
         code: '',
-        time: [],
-        executeUserName: ''
+        releaseTime: [],
+        deliveryTime: [],
+        createTime: []
       };
       return {
         // 表单数据
@@ -116,10 +139,15 @@
       search () {
         const where = this.where;
 
-        if (where.time?.length) {
-          where.startTime = where.time[0];
-          where.endTime = where.time[1];
+        for (const key in where) {
+          if (Array.isArray(where[key]) && where[key].length) {
+            where[`${key}Start`] = where[key][0];
+            where[`${key}End`] = where[key][1];
+          }
         }
+        delete where.releaseTime;
+        delete where.deliveryTime;
+        delete where.createTime;
 
         this.$emit('search', where);
       },

+ 103 - 22
src/views/materialPlan/components/plan-edit-dialog.vue

@@ -1,10 +1,18 @@
 <template>
   <ele-modal
     :visible.sync="visible"
+    :closed="cancel"
     :title="`${type == 'add' ? '创建' : '编辑'}配料计划`"
     custom-class="ele-dialog-form"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
   >
-    <el-form :model="formData" label-width="100px" class="ele-body">
+    <el-form
+      :model="formData"
+      label-width="120px"
+      class="ele-body"
+      :rules="rules"
+    >
       <el-row :gutter="32">
         <el-col :span="12">
           <el-form-item label="选择物料" prop="materialName">
@@ -14,37 +22,50 @@
             ></el-input>
           </el-form-item>
         </el-col>
-        <el-col :span="12">
+        <!-- <el-col :span="12">
           <el-form-item label="生产版本" prop="productVersionName">
             <el-input
+              :disabled="!formData.materialName"
+              placeholder="请选择"
               v-model="formData.productVersionName"
               @click.native="chooseVersion"
             ></el-input>
           </el-form-item>
-        </el-col>
+        </el-col> -->
         <el-col :span="12">
           <el-form-item label="牌号" prop="brandNo">
-            <el-input v-model="formData.brandNo"></el-input>
+            <el-input v-model="formData.brandNo" disabled></el-input>
           </el-form-item>
         </el-col>
-        <el-col :span="12">
+        <!-- <el-col :span="12">
           <el-form-item label="工艺路线名称" prop="brandNo">
             <el-input v-model="formData.aaa"></el-input>
           </el-form-item>
-        </el-col>
+        </el-col> -->
         <el-col :span="12">
           <el-form-item label="要求交付日期" prop="deliveryTime">
-            <el-input v-model="formData.deliveryTime"></el-input>
+            <el-date-picker
+              style="width: 100%"
+              v-model="formData.deliveryTime"
+              type="date"
+              placeholder="选择日期"
+              value-format="yyyy-MM-dd HH:mm:ss"
+            >
+            </el-date-picker>
           </el-form-item>
         </el-col>
-        <el-col :span="12">
+        <!-- <el-col :span="12">
           <el-form-item label="工艺路线版本" prop="brandNo">
             <el-input v-model="formData.aaa"></el-input>
           </el-form-item>
-        </el-col>
+        </el-col> -->
         <el-col :span="12">
           <el-form-item label="生产重量" prop="num">
-            <el-input v-model="formData.num"></el-input>
+            <el-input v-model.number="formData.num">
+              <template slot="suffix">
+                {{ formData.unit }}
+              </template>
+            </el-input>
           </el-form-item>
         </el-col>
         <el-col :span="12">
@@ -56,21 +77,27 @@
     </el-form>
 
     <div slot="footer">
-      <el-button>取消</el-button>
-      <el-button type="primary">确定</el-button>
+      <el-button @click="cancel">取消</el-button>
+      <el-button type="primary" @click="confirm">确定</el-button>
     </div>
 
     <!-- 选择物料 -->
-    <ChooseMaterial ref="chooseRef"></ChooseMaterial>
+    <ChooseMaterial
+      ref="chooseRef"
+      @success="handleChooseMaterial"
+    ></ChooseMaterial>
     <!-- 选择生产版本 -->
-    <ProductionVersion ref="versionRef"></ProductionVersion>
+    <ProductionVersion
+      ref="versionRef"
+      :productCode="formData.categoryId"
+    ></ProductionVersion>
   </ele-modal>
 </template>
 
 <script>
   import ChooseMaterial from '@/components/CreatePlan/ChooseMaterial.vue';
   import ProductionVersion from '@/components/CreatePlan/ProductionVersion.vue';
-
+  import { save, update } from '@/api/materialPlan/index';
   export default {
     components: {
       ChooseMaterial,
@@ -80,22 +107,76 @@
       return {
         visible: false,
         type: 'add',
-        formData: {}
+        rules: {
+          materialName: [
+            {
+              required: true,
+              message: '请选择物料',
+              trigger: ['blur', 'change']
+            }
+          ],
+          deliveryTime: [
+            {
+              required: true,
+              message: '请选择要求交付日期',
+              trigger: ['blur', 'change']
+            }
+          ],
+          num: [
+            {
+              required: true,
+              message: '请输入生产重量',
+              trigger: ['blur', 'change']
+            }
+          ]
+        },
+        formData: {
+          deliveryTime: '',
+          num: '',
+          remark: '',
+          categoryId: '',
+          unit: '',
+          brandNo: '',
+          materialCode: '',
+          materialName: ''
+        }
       };
     },
     methods: {
-      open (type, row = {}) {
+      async open (type, row = {}) {
         this.type = type;
-        this.formData = row;
+        this.formData = Object.assign({}, this.formData, row);
         this.visible = true;
       },
       chooseMateriel () {
-        this.$refs.chooseRef.open();
+        this.$refs.chooseRef.open(this.formData.categoryId);
       },
-
-      chooseVersion () {
-        this.$refs.versionRef.open();
+      handleChooseMaterial (row) {
+        this.formData.materialName = row.name;
+        this.formData.categoryId = row.id;
+        this.formData.materialCode = row.materialCode;
+        this.formData.brandNo = row.brandNum;
+        this.formData.unit = row.measuringUnit;
+      },
+      async confirm () {
+        const request = this.type == 'add' ? save : update;
+        console.log(this.formData, 'this.formData');
+        await request(this.formData);
+        this.$message.success('保存成功!');
+        this.$emit('success');
+        this.cancel();
+      },
+      cancel () {
+        this.visible = false;
+        this.formData = {};
       }
+
+      // chooseVersion () {
+      //   if (!this.formData.materialName) {
+      //     return this.$message.error('请选择物料');
+      //   }
+      //   this.$refs.versionRef.open();
+      // }
     }
   };
 </script>

+ 62 - 30
src/views/materialPlan/index.vue

@@ -1,7 +1,13 @@
 <template>
   <div class="ele-body">
     <el-card shadow="never" v-loading="loading">
-      <materialPlan-search @search="reload" ref="searchRef">
+      <materialPlan-search
+        @search="reload"
+        :statusOpt="statusOpt"
+        :planType="planType"
+        :activeName="activeName"
+        ref="searchRef"
+      >
       </materialPlan-search>
       <el-button
         type="primary"
@@ -47,20 +53,25 @@
           >
             修改计划
           </el-link>
-          <el-link type="primary" :underline="false" icon="el-icon-edit">
+          <el-link
+            type="primary"
+            @click="handleDel(row)"
+            :underline="false"
+            icon="el-icon-edit"
+          >
             删除
           </el-link>
         </template>
       </ele-pro-table>
     </el-card>
-    <planEditDialog ref="planEditDialogRef" />
+    <planEditDialog ref="planEditDialogRef" @success="reload" />
   </div>
 </template>
 
 <script>
   import materialPlanSearch from './components/materialPlan-search.vue';
   import planEditDialog from './components/plan-edit-dialog.vue';
-  import { getList } from '@/api/materialPlan/index';
+  import { getList, del } from '@/api/materialPlan/index';
   export default {
     components: {
       planEditDialog,
@@ -75,7 +86,21 @@
         loading: false,
         pageType: 'add',
         dialogTitle: '',
-        isBindPlan: false
+        isBindPlan: false,
+        statusOpt: {
+          first: [
+            { label: '所有状态', value: '3,2' },
+            { label: '待发布', value: '2' },
+            { label: '发布失败', value: '3' }
+          ],
+          second: [
+            { label: '所有状态', value: '7,3,4,5,6' },
+            { label: '待生产', value: '4' },
+            { label: '生产中', value: '5' },
+            { label: '已完成', value: '6' },
+            { label: '已延期', value: '7' }
+          ]
+        }
       };
     },
     computed: {
@@ -101,28 +126,28 @@
             minWidth: 110
           },
           {
-            prop: 'planCode',
+            prop: 'materialCode',
             label: '编号',
             align: 'center',
             showOverflowTooltip: true,
             minWidth: 110
           },
           {
-            prop: 'planCode',
+            prop: 'materialName',
             label: '物料名称',
             align: 'center',
             showOverflowTooltip: true,
             minWidth: 110
           },
           {
-            prop: 'planName',
+            prop: 'brandNo',
             label: '牌号',
             align: 'center',
             showOverflowTooltip: true,
             minWidth: 110
           },
           {
-            prop: 'equiCode',
+            prop: 'num',
             label:
               this.activeName === 'second'
                 ? '计划生产重量(KG)'
@@ -135,29 +160,29 @@
             ? [
                 {
                   prop: 'code',
-                  label: '生产重量(KG)',
+                  label: '生产重量(KG)',
                   align: 'center',
                   showOverflowTooltip: true,
                   minWidth: 110
                 }
               ]
             : []),
+          // {
+          //   prop: 'productVersionName',
+          //   label: '生产版本',
+          //   align: 'center',
+          //   showOverflowTooltip: true,
+          //   minWidth: 110
+          // },
+          // {
+          //   prop: 'executeUserName',
+          //   label: '工艺版本',
+          //   align: 'center',
+          //   showOverflowTooltip: true,
+          //   minWidth: 110
+          // },
           {
-            prop: 'equiName',
-            label: '生产版本',
-            align: 'center',
-            showOverflowTooltip: true,
-            minWidth: 110
-          },
-          {
-            prop: 'executeUserName',
-            label: '工艺版本',
-            align: 'center',
-            showOverflowTooltip: true,
-            minWidth: 110
-          },
-          {
-            prop: 'planFinishTime',
+            prop: 'deliveryTime',
             label: '要求交付日期',
             align: 'center',
             showOverflowTooltip: true,
@@ -166,7 +191,7 @@
           ...(this.activeName === 'second'
             ? [
                 {
-                  prop: 'code',
+                  prop: 'completeTime',
                   label: '实际完成时间',
                   align: 'center',
                   showOverflowTooltip: true,
@@ -175,21 +200,21 @@
               ]
             : []),
           {
-            prop: 'acceptTime',
+            prop: 'status',
             label: '状态',
             align: 'center',
             showOverflowTooltip: true,
             minWidth: 110
           },
           {
-            prop: 'finishTime',
+            prop: 'createUserName',
             label: '创建人',
             align: 'center',
             showOverflowTooltip: true,
             minWidth: 110
           },
           {
-            prop: 'sj',
+            prop: 'createTime',
             label: '创建时间',
             align: 'center',
             showOverflowTooltip: true,
@@ -235,6 +260,13 @@
       handleEdit (type, row) {
         this.$refs.planEditDialogRef.open(type, row);
       },
+      handleDel ({ id }) {
+        this.$confirm('确认删除当前数据!', '提示').then(async () => {
+          await del([id]);
+          this.$message.success('删除成功!');
+          this.reload();
+        });
+      },
       // 发布工单
       handleOrderPublish (row) {
         this.$router.push({
@@ -246,7 +278,7 @@
       },
 
       /* 刷新表格 */
-      reload (where) {
+      reload (where = {}) {
         this.$refs.table.reload({ page: 1, where });
       },
 

+ 6 - 5
src/views/productionPlan/components/equipment-dailog.vue

@@ -59,10 +59,10 @@
             label: '设备名称',
             prop: 'name'
           },
-          {
-            label: '生产状态',
-            prop: 'status'
-          },
+          // {
+          //   label: '生产状态',
+          //   prop: 'status'
+          // },
           {
             label: '未完成工单数',
             prop: 'incompleteOrderNum'
@@ -75,7 +75,8 @@
             label: '产能',
             prop: 'capacityNum',
             width: 200,
-            formatter: (row) => row.capacityNum + ' ' + row.capacityUnit
+            formatter: (row) =>
+              row.capacityNum + ' ' + row.capacityUnit + '/' + row.capacityTime
           },
           {
             label: '末单牌号',

+ 48 - 7
src/views/productionPlan/components/plan-view.vue

@@ -106,6 +106,8 @@
               :rules="rule.classeId"
             >
               <classesSelect
+                ref="classesSelectRef"
+                :init="false"
                 v-model="row.classeId"
                 @selfChange="(val) => handleClasseChange(val, row)"
               />
@@ -161,6 +163,7 @@
 
   import { release } from '@/api/productionPlan/order.js';
   import { getCode } from '@/api/codeManagement';
+  import { data } from 'ele-admin/lib/ele-pro-table';
   export default {
     components: { equipmentDailog, classesSelect },
     props: {
@@ -231,14 +234,26 @@
         let formingNum = 0;
         let formingWeight = 0;
         this.tableData.forEach((ele) => {
-          formingNum += ele.formingNum || 0;
-          formingWeight += ele.formingWeight || 0;
+          formingNum += +ele.formingNum || 0;
+          formingWeight += +ele.formingWeight || 0;
         });
 
-        return { formingNum, formingWeight };
+        return {
+          formingNum,
+          formingWeight: formingWeight.toFixed(2)
+        };
       }
     },
     watch: {
+      tableData: {
+        immediate: true,
+        handler () {
+          this.$nextTick(() => {
+            this.$refs.classesSelectRef &&
+              this.$refs.classesSelectRef.getList();
+          });
+        }
+      },
       orderList: {
         immediate: true,
         handler () {
@@ -255,10 +270,32 @@
           if (value) {
             this.$confirm('发布工单后不可撤回,确定发布吗?', '发布确认').then(
               async () => {
-                await release(this.tableData);
-
-                this.$message.success('发布成功!');
-                this.$router.go(-1);
+                const loading = this.$loading({
+                  lock: true,
+                  fullscreen: true,
+                  text: '工单发布中...'
+                });
+                try {
+                  // 反显对象会报错 status
+                  const data = await release(
+                    this.tableData.map((i) =>
+                      Object.assign({}, i, {
+                        status: 4,
+                        model: this.infoData.model,
+                        brandNo: this.infoData.brandNo
+                      })
+                    )
+                  );
+                  if (data) {
+                    this.$message.success('发布成功!');
+                  } else {
+                    this.$message.error('发布失败,请重新发布!');
+                  }
+                  this.$router.go(-1);
+                } catch (error) {
+                  console.error(error);
+                }
+                loading.close();
               }
             );
           }
@@ -266,6 +303,10 @@
       },
       // 班次改变选择执行人
       async handleClasseChange (val, row) {
+        if (!val) {
+          row.executorId = '';
+          row.executorName = '';
+        }
         const res = await getExector(val);
 
         let executorId = '';

+ 2 - 1
src/views/productionPlan/workOrderPublish.vue

@@ -165,7 +165,8 @@
       async getReleaseInfoById () {
         const data = await getReleaseInfoById(this.id);
 
-        this.infoData = data;
+        this.infoData = data.productionPlan;
+
         this.orderList = data.workOrderList;
       }
     },

+ 5 - 2
src/views/saleOrder/components/plan-submit.vue

@@ -77,7 +77,8 @@
   export default {
     mixins: [dictMixins],
     props: {
-      info: Object
+      info: Object,
+      type: String
     },
     data () {
       return {
@@ -92,7 +93,9 @@
     methods: {
       open () {
         this.visible = true;
-        this.getPlanCode();
+        if (this.type != 'edit') {
+          this.getPlanCode();
+        }
       },
       cancel () {
         this.visible = false;

+ 1 - 0
src/views/saleOrder/salesToProduction.vue

@@ -285,6 +285,7 @@
       ></ProductionVersion>
       <PlanSubmit
         ref="submitRefs"
+        :type="$route.query.type"
         :info="form"
         @publish="publishData"
       ></PlanSubmit>