mushencc 3 năm trước cách đây
mục cha
commit
a424d28cd2

+ 69 - 31
src/components/selects/reference/index.vue

@@ -148,7 +148,13 @@ export default {
       childrenCheck: {},
       purchaseTypeList: [],
       materialTypeList: [],
-      currencyOrder: null
+      currencyOrder: null,
+      plan_no_list:[],
+      material:[],
+      project_code:[],
+      project_title:[],
+      supply:[],
+      plan_no:[],
     }
   },
   computed: {
@@ -156,16 +162,10 @@ export default {
       switch (this.type) {
         case 1:
           return [//参照采购计划
-            { title: '计划单号', name: 'Select', value: '', placeholder: '请选择计划单号', serverName: 'purchase_order_apply_no' },
-            { title: '采购计划类型', name: 'Select', value: '', placeholder: '请选择采购计划类型', serverName: 'type_id', option: this.purchaseTypeList },
+            { title: '计划单号', name: 'Select', value: '', placeholder: '请选择计划单号', serverName: 'plan_no',option:this.plan_no_list },
+            { title: '采购计划类型', name: 'Select', value: '', placeholder: '请选择采购计划类型', serverName: 'plan_type', option: this.purchaseTypeList },
            
-            { title: '单据日期', start_server: 'start_time', end_server: 'end_time', name: 'Input', start_value: '', end_value: '', isDate: true, start_placeholder: '开始日期', end_placeholder: '结束日期', },
-             { title: '物料分类', name: 'Select', value: '', placeholder: '请选择采购计划类型', serverName: 'type_id', option: this.purchaseTypeList },
-             { title: '物料名称', name: 'Select', value: '', placeholder: '请选择采购计划类型', serverName: 'type_id', option: this.purchaseTypeList },
-             { title: '项目编码', name: 'Select', value: '', placeholder: '请选择采购计划类型', serverName: 'type_id', option: this.purchaseTypeList },
-              { title: '项目名称', name: 'Select', value: '', placeholder: '请选择采购计划类型', serverName: 'type_id', option: this.purchaseTypeList },
-                { title: '建议供应商', name: 'Select', value: '', placeholder: '请选择采购计划类型', serverName: 'type_id', option: this.purchaseTypeList },
-               { title: '单据日期', start_server: 'start_time', end_server: 'end_time', name: 'Input', start_value: '', end_value: '', isDate: true, start_placeholder: '开始日期', end_placeholder: '结束日期', },
+            { title: '单据日期', start_server: 'start_time', end_server: 'end_time', name: 'Input', start_value: '', end_value: '', isDate: true, start_placeholder: '开始日期', end_placeholder: '结束日期', }
           ]
         case 2:
         case 3:
@@ -193,12 +193,12 @@ export default {
       switch (this.type) {
         case 1:
           return [//采购参照请购单
-            { title: '物料分类', name: 'Select', value: '', placeholder: '请选择物料分类', serverName: 'type_id', option: this.materialTypeList },
-            { title: '物料名称', name: 'Input', value: '', placeholder: '请输入物料名称', serverName: 'title' },
-            {title: '项目编码',name:'Select',value:'',placeholder:'请选择项目编码',serverName:'project_code',option:[]},
-            {title: '项目名称',name:'Select',value:'',placeholder:'请选择项目编码',serverName:'project_code',option:[]},
-            {title: '建议供应商',name:'Select',value:'',placeholder:'请选择项目编码',serverName:'project_code',option:[]},
-             { title: '预计到货时间', start_server: 'start_time', end_server: 'end_time', name: 'Input', start_value: '', end_value: '', isDate: true, start_placeholder: '开始日期', end_placeholder: '结束日期', }
+            { title: '物料分类', name: 'Select', value: '', placeholder: '请选择物料分类', serverName: 'material_type_id', option: this.materialTypeList },
+             {title: '物料名称',name:'Select',value:'',placeholder:'请输入物料名称',serverName:'material_title',option:this.material},
+            {title: '项目编码',name:'Select',value:'',placeholder:'请选择项目编码',serverName:'project_code',option:this.project_code},
+            {title: '项目名称',name:'Select',value:'',placeholder:'请选择项目编码',serverName:'project_title',option:this.project_title},
+            {title: '建议供应商',name:'Select',value:'',placeholder:'请选择项目编码',serverName:'supply_id',option:this.supply},
+             { title: '预计到货时间', start_server: 'arrive_start_time', end_server: 'arrive_end_time', name: 'Input', start_value: '', end_value: '', isDate: true, start_placeholder: '开始日期', end_placeholder: '结束日期', }
           ]
         case 2:
         case 3:
@@ -569,20 +569,18 @@ export default {
     }
   },
   mounted () {
+    let type_id = '';
+    if(this.type ==1){
+      type_id = 2
+    }
     // 获取采购类型
-    this.axios({ method: 'get', url: '/api/basic_purchase_list', }).then((res) => {
+    this.axios({ method: 'get', url: '/api/basic_purchase_list',params:{type_id} }).then((res) => {
       this.purchaseTypeList = res.data.data
       this.purchaseTypeList.forEach(element => {
         element.value = element.id
         element.label = element.title
       })
-      if(this.type == 1){
-        this.purchaseTypeList.map((v,index)=>{
-          if(v.type_id !== 1){
-               this.purchaseTypeList.splice(index,1)
-          }
-        })
-      }
+     
     }).catch((err) => { });
     this.$nextTick((e) => {
       const clientTableHeight = window.innerHeight - 51 - 57 -
@@ -618,7 +616,12 @@ export default {
     childrenSearch (row) {
       switch (this.type) {
         case 1:
-          row.purchase_order_apply_no = this.currencyOrder
+          row.plan_no = [];
+          this.plan_no.forEach(v=>{
+            row.plan_no.push(v)
+          })
+          row.arrive_end_time = parseInt(new Date(row.arrive_end_time).getTime() / 1000) || ''
+          row.arrive_start_time= parseInt(new Date(row.arrive_start_time).getTime() / 1000) || ''
           break;
         case 2:
           row.purchase_order_no = this.currencyOrder
@@ -640,17 +643,16 @@ export default {
         //   break;
       }
       this.axios({
-        method: 'get',
+        method: 'post',
         url: this.get_child_url,
-        params: {
-          ...row,
-          type: this.refer_type
+         data:{...row,
+          reference_type: 1
         }
-      }).then((res) => {
+     } ).then((res) => {
         if (res.code == 200) {
           const deep_obj = JSON.parse(JSON.stringify(res.data))
           this.projectDetail = deep_obj
-          this.parts_tableData = res.data
+          this.parts_tableData = res.data.children
         }
       }).catch((err) => { });
     },
@@ -669,6 +671,15 @@ export default {
           res.data.data.map((v) => (v.check = false))
           this.project_tableData = res.data.data
           this.total = res.data.total
+          this.plan_no_list = res.data.plan_no_list;
+          let data = [];
+          this.plan_no_list.forEach(v=>{
+            let obj = {};
+            obj.label = v;
+            obj.value = v;
+            data.push(obj)
+          })
+          this.plan_no_list = data;
         }
       })
     },
@@ -743,6 +754,33 @@ export default {
           selection.forEach(v=>{
              plan_no.push(v.plan_no)
           })
+          this.plan_no = plan_no;
+          this.axios.post('/api/purchase_apply_detail_list',{plan_no}).then(res=>{
+           
+            this.material = res.data.material;
+            this.material.forEach(v=>{
+              v.label = v.title;
+              v.value = v.title;
+            })
+           
+            this.project_code = res.data.project_code;
+            this.project_code.forEach(v=>{
+              v.label = v.project_code;
+              v.value = v.project_code;
+            })
+            this.project_title = res.data.project_title;
+            this.project_title.forEach(v=>{
+               v.label = v.project_title;
+              v.value = v.project_title;
+            })
+           this.supply = res.data.supply;
+           this.supply.forEach(v=>{
+              v.label = v.title;
+              v.value = v.id;
+           })
+            console.log(2)
+           this.$forceUpdate();
+          })
           this.axios({
             method: 'post',
             url: this.get_child_url,

+ 36 - 73
src/views/BasicSettings/rootManage.vue

@@ -12,6 +12,7 @@
                 ghost>新增</Button>
       </slot>
     </Toptitle>
+    <div style="height:80%;overflow:auto">
     <div style="padding-top:20px">
       <Form inline :label-width='50'>
         <FormItem label="用户:">
@@ -53,7 +54,19 @@
           <a @click="handleRowClick(row,index,3)">删除</a>
         </template>
       </Table>
+
+    </div>
     </div>
+    <div style="text-align:center">
+          <Page :page-size-opts="[10, 20, 30, 40,100]"
+                @on-page-size-change='changeSize'
+                @on-change='changePage'
+                :current='pageIndex'
+                show-total
+                :total="total"
+                show-sizer
+                :page-size='pageSize' />
+        </div>
     <Modal class="modal"
            :title='modal_title'
            v-model='showModal'
@@ -90,6 +103,7 @@
            slot="footer">
         <Button @click="showModal = false">取消</Button>
         <Button type="primary"
+        v-if="modal_title !=='查看' "
                 @click="handleColorConfirm">确认</Button>
       </div>
     </Modal>
@@ -109,6 +123,9 @@ export default {
   data () {
     // 这里存放数据
     return {
+      pageSize:10,
+      pageIndex: 1,
+      total: 0,
         process_list:[],
         band_list:[],
         user_list:[],
@@ -118,41 +135,8 @@ export default {
       columns: [
         { title:'ID', key: 'sub_id', align: 'center' },
         { title: '用户', key: 'user', align: 'center', },
-        { title: '工序', key: 'process', align: 'center', 
-          render:(h,params)=>{
-          return h('div',[
-            h('span',{
-              style:{
-                display:"inline-block",
-                width:'100%',
-                overflow:'none',
-                textOverflow:'ellipsis',
-                whiteSpace:"nowrap",
-                cursor: 'pointer'
-              },
-              domProps:{title:params.row.process.toString()},
-              // on:{'click':(e)=>{e.stopPropagation();console.log(1)}}
-            },params.row.process.toString())
-          ])
-        }},
-        { title: '班组', key: 'band', align: 'center',
-           render:(h,params)=>{
-          return h('div',[
-            h('span',{
-              style:{
-                display:"inline-block",
-                width:'100%',
-                overflow:'none',
-                textOverflow:'ellipsis',
-                whiteSpace:"nowrap",
-                cursor: 'pointer'
-              },
-              domProps:{title:params.row.band.toString()},
-              // on:{'click':(e)=>{e.stopPropagation();console.log(1)}}
-            },params.row.band.toString())
-          ])
-        } 
-        },
+        { title: '工序', key: 'process', align: 'center', ellipsis:'true',tooltip:'true'},
+        { title: '班组', key: 'band', align: 'center',ellipsis:'true',tooltip:'true' },
         { title: '操作', key: 'operation', align: 'center', slot: 'op' }
       ],
       tableData: [],
@@ -184,6 +168,16 @@ export default {
       this.init()
   },
   methods: {
+      changeSize (e) {
+      this.pageSize = e;
+      this.init()
+    },
+    changePage (index) {
+      this.pageIndex = index;
+      
+      this.init()
+     
+    },
     init () {
     //   this.$forceUpdate();
       this.axios.post('/api/ext_user_permission_list', 
@@ -191,43 +185,10 @@ export default {
           title: this.search_title
         }
       ).then(res => {
-        if (res.code == 200) {
-            res.data.data.map(v=>{
-                v.process =[];
-                v.band =[];
-            })
-          
+        if (res.code == 200) { 
           this.tableData = res.data.data;
-          
-          this.tableData.forEach(m=>{
-           
-         this.user_list.forEach(v=>{
-                   
-                  if(m.sub_id == v.id){
-                      m.user = v.nickname 
-                  }
-         })
-      m.json.produce_ids.forEach(x=>{
-              this.process_list.forEach(z=>{
-                  if(x==z.id){
-                      m.process.push(z.title);
-                  }
-              })
-          })
-        m.json.employee_ids.forEach(s=>{
-           
-            this.band_list.forEach(c=>{
-
-                if(s==c.id){
-                   
-                    m.band.push(c.nickname)
-                    
-                }
-            })
-        })
-          })
+          this.total = res.data.total;
         }
-          console.log(this.tableData)
       }).catch(err => {  })
     },
     back () {
@@ -255,7 +216,7 @@ export default {
             this.currencyRow.band = row.band;
             this.currencyRow.process = row.process;
           this.showModal = true;
-
+ 
           break;
         case 3:
           this.$Modal.confirm({
@@ -321,10 +282,12 @@ export default {
     },
     onDragDrop (a, b) {
       this.tableData.splice(b, 0, ...this.tableData.splice(a, 1))
+      
     }
   },
   // 监听属性 类似于data概念
-  computed: {},
+  computed: {
+  },
   // 监控data中的数据变化
   watch: {},
   beforeCreate () { }, // 生命周期 - 创建之前
@@ -351,7 +314,7 @@ export default {
   }
 }
 /deep/ .ivu-select-selection{
-    width: 300px;
+   
   
 }
 </style>

+ 1 - 1
src/views/ProcedureMannage/edit.vue

@@ -52,7 +52,7 @@
           </div>
         </FormItem>
         <FormItem label="默认班组">
-          <Select v-model="info.employee_id" transfer>
+          <Select v-model="info.employee_id" transfer clearable>
             <Option
               v-for="_item in employeeList"
               :key="_item.id"

+ 3 - 1
src/views/ProductionOrderList/Deliverylist/DeliveryDetail.vue

@@ -198,8 +198,10 @@ export default {
           title: "图号",
           name: "Select",
           serverName: "url_number",
-          placeholder: "请选择产品",
+          placeholder: "请选择图号",
           value: "",
+          multiple:true,
+          filterable:true,
           option: [],
         },
         {

+ 2 - 1
src/views/ProductionOrderList/Deliverylist/Deliverylist.vue

@@ -347,7 +347,8 @@ export default {
         {
           title: "图号",
           name: "Select",
-          filterable:'true',
+          filterable:true,
+          multiple:true,
           serverName: "url_number",
           placeholder: "请选择",
           value: "",

+ 2 - 1
src/views/ProductionOrderList/Dispatchlist/confirm.vue

@@ -187,6 +187,7 @@ export default {
         {
           title: "图号",
           filterable: true,
+          multiple:true,
           name: "Select",
           value: "",
           optionName: "title",
@@ -298,7 +299,7 @@ export default {
       this.axios.post(url, data).then((res) => {
         if (res.code == 200) {
           this.$Message.success(res.msg);
-          this.getData(this.$route.query);
+          this.getData({...this.$route.query,...this.proxyObj});
         }
       });
     },

+ 1 - 1
src/views/ProductionOrderList/Dispatchlist/list.vue

@@ -127,7 +127,7 @@ export default {
             { label: '生产完成', value: 2 },
           ]
         },
-         { title: '图号', name: 'Select', serverName: 'url_number', placeholder: '请选择', value: '', optionName: 'label', optionValue: 'value', option: this.url_number_list,filterable:'true' },
+         { title: '图号', name: 'Select', serverName: 'url_number', placeholder: '请选择', value: '', optionName: 'label', optionValue: 'value', option: this.url_number_list,filterable:true,multiple:true },
         { title: '开始派工时间', name: 'Input', start_server: 'start_time', end_server: 'end_time', start_value: '', end_value: '', isDate: true, serverName: 'id2', start_placeholder: '开始日期', end_placeholder: '结束日期' },
         // {
         //   title: '订单类型', name: 'Select', serverName: 'renovation_type', placeholder: '请选择订单类型', value: '',

+ 1 - 0
src/views/ProductionOrderList/ProductionPlanlist/BST_two.vue

@@ -534,6 +534,7 @@ export default {
           optionName: "title",
           optionValue: "title",
           option: this.url_number_list,
+          multiple:true
         },
         // {
         //   title: "订单类型",

+ 167 - 46
src/views/PurchasingManage/PurchasingOrder/edit.vue

@@ -20,18 +20,18 @@
       </slot>
     </Toptitle>
     <div class="content_topform">
-      <Form :label-width="90"
+      <Form :label-width="120"
             :model="searchData">
-             <FormItem label="订单号:">
+             <FormItem label="订单号:" :label-width='80'>
           <Input type="text"
                  size="small"
                  v-show="!isCheck"
                  disabled
-                 v-model="searchData.residential_name"
+                 v-model="searchData.order_no"
                  style="width: 200px;margin-top:6px"
                  placeholder="自动生成订单号">
           </Input>
-          <span v-show="isCheck">{{searchData.residential_name}}</span>
+          <span v-show="isCheck">{{searchData.order_no}}</span>
         </FormItem>
         <!-- <FormItem label="项目名称:">
           <Input type="text"
@@ -51,7 +51,7 @@
                  size="small"
                  v-show="!isCheck"
                  v-model="searchData.supply_title"
-                 style="width: 200px;margin-top:6px"
+                 style="width: 300px;margin-top:6px"
                  placeholder="供应商名称">
           <span slot="append"
                 style="cursor:pointer;"
@@ -59,8 +59,8 @@
           </Input>
           <span v-show="isCheck">{{searchData.supply_title}}</span>
         </FormItem>
-        <FormItem label="采购订单类型:">
-          <Select v-model="searchData.type_id"
+        <FormItem label="采购订单类型:" style="margin-left:100px">
+          <Select v-model="searchData.basics_purchase_id"
                   size="small"
                   v-show="!isCheck"
                   clearable
@@ -73,7 +73,7 @@
                     :value="sitem.id">
             </Option>
           </Select>
-          <span v-show="isCheck">{{searchData.type_title}}</span>
+          <span v-show="isCheck">{{searchData.basics_purchase_title}}</span>
         </FormItem>
         <!-- <FormItem label="单据号:">
           <Input type="text"
@@ -102,25 +102,25 @@
           </Select> -->
           <!-- <span>{{searchData.nickname}}</span>
         </FormItem> -->
-        <!-- <FormItem label="单日期:">
+        <FormItem label="单日期:">
           <DatePicker type="date"
                       v-show="!isCheck"
                       size="small"
                       style="width: 200px"
                       placeholder="年/月/日"
-                      v-model="searchData.crt_time"></DatePicker>
-          <span v-show="isCheck">{{func.replaceDate(searchData.crt_time)}}</span>
-        </FormItem> -->
-        <FormItem label="预计到货日期:">
+                      v-model="searchData.order_time"></DatePicker>
+          <span v-show="isCheck">{{searchData.order_time?func.replaceDate(searchData.order_time).split(' ')[0]:''}}</span>
+        </FormItem>
+        <FormItem label="预计到货日期:" style="margin-left:30px">
           <DatePicker type="date"
                       v-show="!isCheck"
                       size="small"
                       style="width: 200px"
                       placeholder="年/月/日"
                       v-model="searchData.arrive_time"></DatePicker>
-          <span v-show="isCheck">{{func.replaceDate(searchData.arrive_time)}}</span>
+          <span v-show="isCheck">{{searchData.arrive_time?func.replaceDate(searchData.arrive_time).split(' ')[0]:''}}</span>
         </FormItem>
-        <FormItem label="备注:">
+        <FormItem label="备注:" :label-width='80'>
           <Input type="textarea"
                  v-show="!isCheck"
                  size="small"
@@ -133,15 +133,15 @@
     </div>
     <div class="content_table">
       <div class="content_table_btn">
-        <div>
-          <span>采购清单</span>
+        <div style="display:flex;">
+          <span style="width:200px">采购清单</span>
           <!-- <Button @click="showModal=true"
                   v-show="!isCheck"
                   type="primary"
                   size="small"
                   style="margin-left:10px;"
                   :disabled="$route.query.is_refer == 0?true:btn_disable">选择物料</Button> -->
-          <div><span>参照计划单号:</span><span></span></div>
+          <div ><span>参照计划单号:</span><span v-for="(item,index) in plan_no" :key="index" style="margin-right:10px">{{item}}{{index+1==plan_no.length?'':','}}</span></div>
         </div>
         <div class="content_table_btn_right"
              v-show="!isCheck">
@@ -207,7 +207,7 @@
               >
               </Option>
             </Select>
-            <span v-show="isCheck||row.project_number == '查看'" @click="check(row)" style="color: rgb(45, 140, 240);cursor: pointer;">{{row.project_code}}</span>
+            <span v-show="isCheck||row.project_number == '查看'" @click="check(row)" style="color: rgb(45, 140, 240);cursor: pointer;">{{row.project_number=='查看'?'查看':row.project_code}}</span>
             </div>
         </template>
         <template slot="project_title" slot-scope="{ row,index }">
@@ -231,7 +231,7 @@
               >
               </Option>
             </Select>
-            <span v-show="isCheck||row.project_number == '查看'" @click="check(row)" style="color: rgb(45, 140, 240);cursor: pointer;">{{row.project_title}}</span>
+            <span v-show="isCheck||row.project_number == '查看'" @click="check(row)" style="color: rgb(45, 140, 240);cursor: pointer;">{{row.project_number=='查看'?'查看':row.project_title}}</span>
             </div>
         </template>
        <template slot="numberSet" slot-scope="{row , index }">
@@ -249,13 +249,15 @@
               </div>
             </div>
             <Input
-              type="text"
+            
               v-show="!isCheck"
               size="small"
               v-model="tableData[index].num"
               placeholder="数量"
-              on-change="changenum"
+              @on-change="changenum($event,row,index)"
+              :disabled="row.project_number == '查看'"
             >
+            
             </Input>
             <span v-show="isCheck">{{ tableData[index].num }}</span>
             </Tooltip>
@@ -495,6 +497,7 @@ export default {
   data () {
     // 这里存放数据
     return {
+      delData:[],
       material_name:'',
       checkData:[],
       CheckTableColumns:[
@@ -626,6 +629,9 @@ export default {
                   currentRow.price = (1 * currentRow.no_tax_price * (1 + 1 * currentRow.fax / 100)).toFixed(2)
                   currentRow.total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
                   currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
+                   if(!currentRow.copy&&!currentRow.edit){
+        currentRow.change = true;
+      }
                   // currentRow.total_price = (1 * currentRow.no_tax_amount + 1 * currentRow.tax_amount).toFixed(2)
                   this.tableData.splice(index, 1, currentRow);
                 }
@@ -654,6 +660,9 @@ export default {
                   currentRow.price = (1 * currentRow.no_tax_price * (1 + 1 * currentRow.fax / 100)).toFixed(2)
                   currentRow.total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
                   currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
+                   if(!currentRow.copy&&!currentRow.edit){
+        currentRow.change = true;
+      }
                   this.tableData.splice(index, 1, currentRow);
                 }
               }
@@ -681,7 +690,10 @@ export default {
                   currentRow.no_tax_price = (1 * currentRow.price / (1 + 1 * currentRow.fax / 100)).toFixed(2)
                   currentRow.total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
                   currentRow.no_tax_amount = (1 * currentRow.no_tax_price * currentRow.num).toFixed(2)
-                  currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_price).toFixed(2)
+                  currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
+                   if(!currentRow.copy&&!currentRow.edit){
+        currentRow.change = true;
+      }
                   this.tableData.splice(index, 1, currentRow);
                 }
               }
@@ -705,10 +717,13 @@ export default {
               on: {
                 'on-change': (e) => {
                   currentRow.no_tax_amount = e.target.value
-                  currentRow.no_tax_price = (1 * currentRow.no_tax_amount / currentRow.num).toFixed(2)
+                  currentRow.no_tax_price = (1 * currentRow.no_tax_amount / 1*currentRow.num).toFixed(2)
                   currentRow.price = (1 * currentRow.no_tax_price * (1 + 1 * currentRow.fax / 100)).toFixed(2)
                   currentRow.total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
                   currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
+                   if(!currentRow.copy&&!currentRow.edit){
+        currentRow.change = true;
+      }
                   this.tableData.splice(index, 1, currentRow);
                 }
               }
@@ -735,6 +750,9 @@ export default {
                   // currentRow.fax = (1 * currentRow.tax_amount / currentRow.no_tax_price).toFixed(2)
                  currentRow.no_tax_amount = (1*(currentRow.total_price-currentRow.tax_amount)).toFixed(2)
                  currentRow.no_tax_price = (1*(currentRow.no_tax_amount/currentRow.num)).toFixed(2)
+                  if(!currentRow.copy&&!currentRow.edit){
+        currentRow.change = true;
+      }
                   this.tableData.splice(index, 1, currentRow);
                 }
               }
@@ -762,6 +780,9 @@ export default {
                   currentRow.no_tax_price = (1 * currentRow.price / (1 + 1 * currentRow.fax / 100)).toFixed(2)
                   currentRow.no_tax_amount = (1 * currentRow.no_tax_price * currentRow.num).toFixed(2)
                   currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
+                   if(!currentRow.copy&&!currentRow.edit){
+        currentRow.change = true;
+      }
                   this.tableData.splice(index, 1, currentRow);
                 }
               }
@@ -913,6 +934,7 @@ export default {
       warningList: [],
       purchase_data:[],
       purchase_tableData:[],
+      plan_no:[],
     }
   },
   // 生命周期 - 创建完成(可以访问当前this实例)
@@ -921,7 +943,7 @@ export default {
     // 获取操作员
     this.axios('/api/user').then(res => this.usersList = res.data.data)
     // 获取采购类型
-    this.axios({ method: 'get', url: '/api/basic_purchase_list', }).then((res) => { this.purchaseTypeList = res.data.data }).catch((err) => { });
+    this.axios({ method: 'get', url: '/api/basic_purchase_list',params:{type_id:2} }).then((res) => { this.purchaseTypeList = res.data.data }).catch((err) => { });
     // 获取基础物料类型
     this.axios({ method: 'get', url: '/api/basics_material_index_level', }).then((res) => { this.modalData.treeData[0].list = res.data }).catch((err) => { });
     // 获取供应商列表
@@ -947,11 +969,17 @@ export default {
   },
   // 生命周期 - 挂载完成(可以访问DOM元素)
   mounted () {
-    if (this.$route.query.purchase_order_no != '') {
-      this.initData(this.$route.query.purchase_order_no)
+    if (this.$route.query.order_no != '') {
+      this.initData(this.$route.query.order_no)
     }
   },
   methods: {
+    selectChange(row,index){
+      if(!row.copy&&!row.edit){
+        this.tableData[index].change = true;
+        console.log(this.tableData)
+      }
+   },
     check(row){
       console.log(row);
       if(row.project_number!=='查看'){
@@ -987,17 +1015,19 @@ export default {
  switch(this.total_type){
         case 1:
           this.tableData.map((v)=>{
-           
+           if(v.project_number == '查看'){
+             return
+           }else{
             this.selectChoose.map(m=>{
               if(m.index == v.index ){
-                     v.project_code =this.total_project_info.code;
-            v.project_title = this.total_project_info.name;
+                     v.project_code =this.total_project_info.code?this.total_project_info.code:v.project_code;
+            v.project_title = this.total_project_info.name?this.total_project_info.name:v.project_title;
                v._checked = true;
                v.ad = true
               }
           
             })
-        
+           }
           })
           break;
           case 2:
@@ -1074,12 +1104,18 @@ if(this.selectChoose.length == 0){
       this.showTotal = true;
       this.total_type = val;
     },
-    changenum(e){
+    changenum(e,currentRow,index){
+      console.log(currentRow)
          currentRow.num = e.target.value
                   currentRow.total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
+                  this.tableData[index].total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
                   currentRow.no_tax_amount = (1 * currentRow.no_tax_price * currentRow.num).toFixed(2)
+                  this.tableData[index].no_tax_amount = (1 * currentRow.no_tax_price * currentRow.num).toFixed(2)
                   currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
-                  this.tableData.splice(index, 1, currentRow);
+                  this.tableData[index].tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
+                 if(!this.tableData[index].copy&&!this.tableData[index].edit){
+       this.tableData[index].change = true;
+      }
     },
        handleToolShow(index, row) {
       if (this.warehouse) {
@@ -1099,31 +1135,48 @@ if(this.selectChoose.length == 0){
       // this.warehouse.num = this.warehouseTotal[index].num;
       // this.warehouse.warehouseName = this.warehouseTotal[index].warehouseName
     },
-    initData (purchase_order_no) {
+    initData (order_no) {
       this.axios({
         method: 'get',
         url: '/api/purchase_detail',
-        params: { purchase_order_no }
+        params: { order_no }
       }).then((res) => {
-        this.tableData = res.data.list
+         if(this.$route.query.type==2){
+              this.tableData = []
+          }
+          
+          this.tableData=res.data.list;
         const data = JSON.parse(JSON.stringify(res.data))
         delete data.list
         this.searchData = data
         this.searchData.crt_time = this.func.replaceDate(this.searchData.crt_time)
         this.searchData.arrive_time = this.func.replaceDate(this.searchData.arrive_time)
-        this.searchData.supply_title = this.tableData[0].supply_title || null
+        this.searchData.order_time = this.func.replaceDate(this.searchData.order_time)
         this.searchData.supply_id = this.tableData[0].supply_id || null
         this.tableData.forEach(element => {
-          element.no_tax_price = (1 * element.price / (1 + 1 * element.fax / 100)).toFixed(2)
+          if(element.state==1){
+            element.project_number = '查看'
+          }
+          element.material_type = element.type_title;
+          element.material_title = element.title;
+          element.fax = 1*element.tax_rate*100;
+          element.no_tax_price = (1 * element.price / (1 + 1*element.tax_rate)).toFixed(2)
           element.no_tax_amount = (1 * element.no_tax_price * element.num).toFixed(2)
           element.total_price = (1 * element.price * element.num).toFixed(2)
           element.tax_amount = (1 * element.total_price - 1 * element.no_tax_amount).toFixed(2)
         });
+        if(this.$route.query.type!==2){
+          this.tableData.push({material_title:'选择物料',_disabled:true})
+        }
+        console.log(this.tableData)
       }).catch((err) => { });
     },
     postData () {
+       if(!this.searchData.order_time){
+       return this.$Message.warning('请选择单据日期')
+      };
       let obj = JSON.parse(JSON.stringify(this.searchData))
-      obj.crt_time = parseInt(new Date(obj.crt_time).getTime() / 1000) || ''
+      obj.order_time = parseInt(new Date(obj.order_time).getTime() / 1000) || ''
       obj.arrive_time = parseInt(new Date(obj.arrive_time).getTime() / 1000) || ''
       // if(this.tableData == null){
       //   this.confirmDelete({
@@ -1137,15 +1190,39 @@ if(this.selectChoose.length == 0){
       //   cancel: () => { }
       // })
       // }
-      if (this.$route.query.purchase_order_no == '') {
+      if (this.$route.query.type == 1||this.$route.query.type == 6) {
         // 新增
+        let children=[];
+       
+        this.tableData.forEach(v=>{
+            let obj={};
+            obj.material_id=v.material_id;
+            obj.material_detail_id = v.material_detail_id ;
+            obj.project_code = v.project_code;
+            obj.project_title = v.project_title ;
+            obj.num = v.num;
+            obj.price = v.price;
+            obj.tax_rate = (1*v.fax)/100;
+            if(v.project_number == '查看'){
+              obj.state = 1
+            }else{
+              obj.state =0
+            };
+           this.purchase_data.forEach(m=>{
+             if(v.material_detail_id = m[0].material_detail_id){
+                  obj.children=[...m]
+             }
+           })
+           children.push(obj)
+        })
+        
+         children.pop();
         this.axios({
           method: 'post',
           url: '/api/purchase_add',
           data: {
             ...obj,
-            list: this.tableData,
-            is_refer:this.table_state,
+           children
           }
         }).then((res) => {
           if (res.code == 200) {
@@ -1154,15 +1231,33 @@ if(this.selectChoose.length == 0){
           }
         }).catch((err) => { });
       } else {
+          let objData = [];
+        objData =JSON.parse(JSON.stringify(this.tableData)); 
+        objData.pop();
+         let upd_list = [];
+         let add_list = [];
+         let del_list = this.delData;
+         objData.forEach(v=>{
+           if(v.edit||v.copy){
+              add_list.push(v)
+           }
+            if(v.change||v.ad){
+              if(!v.edit||!v.copy){
+                 upd_list.push(v)
+              }
+            
+           }
+         })
         // 编辑
         this.axios({
           method: 'post',
           url: '/api/purchase_edit',
           data: {
-            purchase_order_no: this.$route.query.purchase_order_no,
+            order_no: this.$route.query.order_no,
             ...obj,
-            list: this.tableData,
-            is_refer:this.table_state
+            upd_list,
+          add_list,
+          del_list
           }
         }).then((res) => {
           if (res.code == 200) {
@@ -1275,6 +1370,14 @@ if(this.selectChoose.length == 0){
            this.purchase_tableData.push(data)
           })
           console.log(this.purchase_tableData);
+          this.plan_no = [];
+          this.purchase_data.forEach(v=>{
+            v.forEach(m=>{
+               if(this.plan_no.indexOf(m.plan_no)<0){
+                 this.plan_no.push(m.plan_no)
+               }
+            })
+          })
         this.tableData = [{material_title:'选择物料',_disabled:true}];
           this.tableData.unshift(...this.purchase_tableData,...this.modalData.selectedData)
           // this.searchData.residential_name = result[0].residential_name
@@ -1292,22 +1395,40 @@ if(this.selectChoose.length == 0){
         if(row.project_number == '查看'){
           let obj = JSON.parse(JSON.stringify(row));
           obj.project_number = '';
+          obj.id=obj.id+''+'a';
+          // console.log(row);
+          // console.log(obj)
           this.tableData.splice(index+1,0,obj)
+          this.modalData.selectedData.push(obj)
+           row.copy=true;
+          // console.log(this.tableData)
         }else{
-           this.tableData.splice(index+1,0,row);}
+           this.tableData.splice(index+1,0,row);
+           this.modalData.selectedData.push(row)
+            row.copy=true;
+           }
       }else if(type == 4){
+        if(!row.copy&&!row.edit){
+          this.delData.push(row.id)
+        }
       this.tableData.splice(index, 1);
       this.purchase_data.forEach((v,idx)=>{
         if(row.material_detail_id == v[0].material_detail_id){
               this.purchase_data.splice(idx,1)
         }
       })
+      this.modalData.selectedData.forEach((m,idx)=>{
+        if(row.id === m.id){
+             this.modalData.selectedData.splice(idx,1)
+        }
+      })
       }else{
         return
       }
     },
     handleSelect () {
       this.modalData.selectedData.forEach(element => {
+        element.edit = true;
         element.material_title = element.title
         element.num = 0
         element.no_tax_price = 0

+ 63 - 55
src/views/PurchasingManage/PurchasingOrder/list.vue

@@ -13,9 +13,9 @@
     </Toptitle>
     <div class="content">
     <div class="purchase_order_search">
-      <Form :label-width="90"
+      <Form :label-width="100"
             :model="searchData">
-        <FormItem label="订单号:">
+        <FormItem label="订单号:" style="width:300px">
           <Input type="text"
                  size="small"
                  v-model="searchData.order_no"
@@ -23,7 +23,7 @@
                  clearable
                  placeholder="订单号" />
         </FormItem>
-         <FormItem label="采购订单类型:">
+         <FormItem label="采购订单类型:" style="width:300px">
           <Select v-model="searchData.type_id"
                   size="small"
                   clearable
@@ -37,7 +37,7 @@
             </Option>
           </Select>
         </FormItem>
-        <FormItem label="供应商名称:">
+        <FormItem label="供应商名称:" style="width:300px">
           <Input type="text"
                  size="small"
                  v-model="searchData.supply_title"
@@ -45,19 +45,21 @@
                  clearable
                  placeholder="供应商名称" />
         </FormItem>
-        <FormItem label="订单状态:">
+        <FormItem label="订单状态:" style="width:300px">
           <Select v-model="searchData.lock"
                   size="small"
                   clearable
                   style="width: 150px">
-            <Option label='正常'
-                    :value=0 />
             <Option label='已关闭'
-                    :value=1 />
+                    :value='0' />
+            <Option label='部分关闭'
+                    :value='1' />
+                    <Option label='正常'
+                    :value='2' />
           </Select>
         </FormItem>
-        <FormItem label="制单人:">
-          <Select v-model="searchData.user_id"
+        <FormItem label="制单人:" style="width:300px">
+          <Select v-model="searchData.crt_id"
                   size="small"
                   clearable
                   style="width: 150px">
@@ -69,23 +71,19 @@
           </Select>
         </FormItem>
        
-        <FormItem label="审批状态:">
+        <FormItem label="审批状态:" style="width:300px">
           <Select v-model="searchData.state"
                   size="small"
                   clearable
                   style="width: 150px">
-            <Option label='未提交'
-                    :value=0 />
-            <Option label='审核中'
-                    :value=1 />
-            <Option label='通过'
-                    :value=2 />
-            <Option label='驳回'
-                    :value=3 />
+            <Option label='未审核'
+                    :value='0' />
+            <Option label='已审核'
+                    :value='1' />
           </Select>
         </FormItem>
-        <FormItem label="审批人:">
-          <Select v-model="searchData.user_id"
+        <FormItem label="审批人:" style="width:300px">
+          <Select v-model="searchData.check_id"
                   size="small"
                   clearable
                   style="width: 150px">
@@ -96,35 +94,35 @@
             </Option>
           </Select>
         </FormItem>
-        <FormItem label="预计到货日期:">
+        <FormItem label="预计到货日期:" style="width:500px">
           <DatePicker type="date"
                       size="small"
                       style="width: 150px"
                       placeholder="年/月/日"
-                      v-model="searchData.start_time"></DatePicker>
+                      v-model="searchData.arrive_start_time"></DatePicker>
        
        ~
           <DatePicker type="date"
                       size="small"
                       style="width: 150px"
                       placeholder="年/月/日"
-                      v-model="searchData.end_time"></DatePicker>
+                      v-model="searchData.arrive_end_time"></DatePicker>
         </FormItem>
-         <FormItem label="单据日期:">
+         <FormItem label="单据日期:" style="width:500px">
           <DatePicker type="date"
                       size="small"
                       style="width: 150px"
                       placeholder="年/月/日"
-                      v-model="searchData.start_time"></DatePicker>
+                      v-model="searchData.order_start_time"></DatePicker>
        
        ~
           <DatePicker type="date"
                       size="small"
                       style="width: 150px"
                       placeholder="年/月/日"
-                      v-model="searchData.end_time"></DatePicker>
+                      v-model="searchData.order_end_time"></DatePicker>
         </FormItem>
-         <FormItem label="订单创建时间:">
+         <FormItem label="订单创建时间:" style="width:500px">
           <DatePicker type="date"
                       size="small"
                       style="width: 150px"
@@ -167,9 +165,8 @@
             <a style="margin:0 5px"
                :disabled="row.state==1||row.state==2"
                @click="handleSet(4,row,index)">删除</a>
-            <a style="margin:0 5px"
-               :disabled="row.state==1||row.state==2"
-               @click="handleSet(5,row,index)">审批/弃审</a>
+          <a style="margin:0 5px"
+               @click="handleSet(5,row,index)">{{row.state==0?'审批':'弃审'}}</a>
           </template>
         </Table>
       </div>
@@ -212,26 +209,31 @@ export default {
         state: '',
         start_time: '',
         end_time: '',
+         arrive_start_time:'',
+        arrive_end_time:'',
+          order_start_time:'',
+        order_end_time:'',
+       
       },
       purchaseTypeList: [],
       tableColumns: [
-        { title: '订单号', key: 'purchase_order_no', align: 'center', minWidth: 140 },
-        { title: '采购订单类型', key: 'type_title', align: 'center', minWidth: 140 },
+        { title: '订单号', key: 'order_no', align: 'center', minWidth: 140 },
+        { title: '采购订单类型', key: 'basics_purchase_title', align: 'center', minWidth: 140 },
         { title: '供应商名称', key: 'supply_title', align: 'center', minWidth: 140 },
         {
           title: '订单状态', key: 'lock', align: 'center', minWidth: 120,
-          render: (h, params) => {
+        render: (h, params) => {
             const { row } = params
-            const text = row.lock == 0 ? '正常' : '已关闭'
+            const text = row.lock == 0 ? '已关闭' :row.lock == 1?'部分关闭':'正常'
             return h('span', {}, text)
           }
         },
-        { title: '制单人', key: 'nickname', align: 'center', minWidth: 100 },
+        { title: '制单人', key: 'check_name', align: 'center', minWidth: 100 },
         {
           title: '审批状态', key: 'state', align: 'center', minWidth: 140,
-          render: (h, params) => {
+        render: (h, params) => {
             const { row } = params
-            const text = row.state == 0 ? '未提交' : row.state == 1 ? '审核中' : row.state == 2 ? '通过' : '驳回'
+            const text = row.state == 0 ? '未审批' : '已审批'
             return h('span', {}, text)
           }
         },
@@ -243,20 +245,20 @@ export default {
           }
         },
         {
-          title: '单据日期', key: 'crt_time', align: 'center', minWidth: 140,
+          title: '单据日期', key: 'order_time', align: 'center', minWidth: 140,
           render: (h, params) => {
             const { row } = params
-            return h('span', {}, this.func.replaceDate(row.crt_time))
+            return h('span', {}, this.func.replaceDate(row.order_time).split(' ')[0]||'')
           }
         },
          {
-          title: '订单创建时间', key: 'crt_time', align: 'center', minWidth: 140,
+          title: '订单创建时间', key: 'crt_time', align: 'center', minWidth: 170,
           render: (h, params) => {
             const { row } = params
             return h('span', {}, this.func.replaceDate(row.crt_time))
           }
         },
-        { title: '操作', key: 'code', align: 'center', minWidth: 200, slot: 'setSlot' },
+        { title: '操作', key: 'code', align: 'center', minWidth: 250, slot: 'setSlot' },
       ],
       tableData: [{}],
       historyTableData:[],
@@ -269,7 +271,7 @@ export default {
   // 生命周期 - 创建完成(可以访问当前this实例)
   created () {
     // 获取采购类型
-    this.axios({ method: 'get', url: '/api/basic_purchase_list', }).then((res) => { this.purchaseTypeList = res.data.data }).catch((err) => { });
+    this.axios({ method: 'get', url: '/api/basic_purchase_list',params:{type_id:2} }).then((res) => { this.purchaseTypeList = res.data.data }).catch((err) => { });
     // 获取操作员
     this.axios('/api/user').then(res => this.userList = res.data.data)
   },
@@ -296,6 +298,10 @@ export default {
       let obj = JSON.parse(JSON.stringify(this.searchData))
       obj.start_time = parseInt(new Date(obj.start_time).getTime() / 1000) || ''
       obj.end_time = parseInt(new Date(obj.end_time).getTime() / 1000) || ''
+      obj.order_start_time = parseInt(new Date(obj.order_start_time).getTime() / 1000) || ''
+      obj.order_end_time = parseInt(new Date(obj.order_end_time).getTime() / 1000) || ''
+       obj.arrive_start_time = parseInt(new Date(obj.arrive_start_time).getTime() / 1000) || ''
+      obj.arrive_end_time = parseInt(new Date(obj.arrive_end_time).getTime() / 1000) || ''
       this.axios({
         method: 'get',
         url: '/api/purchase_list',
@@ -313,8 +319,9 @@ export default {
       switch (type) {
         case 1:
         case 2:
+          case 6:
         case 3:
-          this.handleGoPage(type, row.purchase_order_no,row.is_refer)
+          this.handleGoPage(type, row.order_no)
           break;
         case 4:
           this.$Modal.confirm({
@@ -325,7 +332,7 @@ export default {
                 method: 'post',
                 url: '/api/purchase_del',
                 data: {
-                  purchase_order_no: row.purchase_order_no
+                  order_no: row.order_no
                 }
               }).then((res) => {
                 this.$Message.success(res.msg)
@@ -337,15 +344,16 @@ export default {
           break;
         case 5:
           this.$Modal.confirm({
-            title: '确认提交?',
+            title: '确认审核?',
+            // content: '此操作无法恢复,请确认!',
             onOk: () => {
               this.axios({
-                method: 'post',
-                url: '/api/purchase_pull',
-                data: {
-                  purchase_order_no: row.purchase_order_no,
-                  lock: row.lock,
-                  state: row.state + 1
+                method: 'get',
+                url: '/api/purchase_check',
+                params: {
+                  order_no: row.order_no,
+                  // lock: row.lock,
+                  state: row.state==0?1:0,
                 }
               }).then((res) => {
                 this.$Message.success(res.msg)
@@ -357,13 +365,13 @@ export default {
           break;
       }
     },
-    handleGoPage (type, purchase_order_no,is_refer) {
+    handleGoPage (type, order_no) {
       this.$router.push({
         path: '/cms/PurchasingManage/PurchasingOrder/edit',
         query: {
           type,
-          purchase_order_no,
-         is_refer
+          order_no,
+         
         }
       })
     },