whj 1 rok temu
rodzic
commit
c460db5a5f

+ 26 - 0
src/api/purchase/purchase-order.js

@@ -491,3 +491,29 @@ export function getPurchasePrice (parameter) {
     }
   })
 }
+/**
+ * export file
+ * parameter: { }
+ * @param parameter :
+ * @returns {*}
+ */
+export function mergePurchase (parameter) {
+  return axios({
+    url: `/merge/merge/${parameter.title}`,
+    method: 'post',
+    data: parameter
+  })
+}
+/**
+ * export file
+ * parameter: { }
+ * @param parameter :
+ * @returns {*}
+ */
+export function updatamergePurchase (parameter) {
+  return axios({
+    url: `/merge/merge/${parameter.id}`,
+    method: 'put',
+    data: parameter
+  })
+}

+ 34 - 6
src/views/purchase/purchase-order-page/PurchaseOrderPage.vue

@@ -9,6 +9,18 @@
                 <a-input v-model.trim="queryParam.keyword" placeholder="请输入请购人员"/>
               </a-form-item>
             </a-col>
+            <a-col :md="8" :sm="24">
+              <a-form-item label="采购单状态">
+                <a-select v-model="queryParam.status" placeholder="请选择">
+                  <a-select-option
+                    v-for="(label,value) in statusMap"
+                    :key="value"
+                    :label="label"
+                    :value="parseInt(value)">{{ label }}
+                  </a-select-option>
+                </a-select>
+              </a-form-item>
+            </a-col>
             <a-col :md="8 || 24" :sm="24">
               <span class="table-page-search-submitButtons">
                 <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
@@ -22,16 +34,19 @@
       <div class="table-operator" style="margin-bottom: 8px;">
         <a-button v-if="$auth('longyanpurchaseorder-menu-add')" type="primary" icon="plus" @click="$refs.baseForm.base()">采购申请</a-button>
         <!--        <a-button v-if="$auth('purchase-purchase-orders-add')" style="margin-left: 8px" type="primary" icon="plus" @click="$refs.addSpareForm.base()">新增物料</a-button>-->
-        <!-- <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('purchase-purchase-orders-del')">
-          <a-menu slot="overlay">
+        <a-dropdown v-if="selectedRowKeys.length > 0 ">
+          <!-- <a-menu slot="overlay">
             <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
               <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
             </a-popconfirm>
+          </a-menu> -->
+          <a-menu slot="overlay">
+            <a-menu-item key="1" @click="handleMerge"><a-icon type="apartment" />合并</a-menu-item>
           </a-menu>
           <a-button style="margin-left: 8px">
             批量操作 <a-icon type="down" />
           </a-button>
-        </a-dropdown> -->
+        </a-dropdown>
       </div>
 
       <s-table
@@ -77,6 +92,7 @@
     </div>
     <BaseForm ref="baseForm" @ok="handleOk"/>
     <Detail ref="detail" @ok="handleOk"/>
+    <MargeModal ref="margeModal" @ok="handleOk"/>
     <AddSpareForm ref="addSpareForm" />
   </a-card>
 </template>
@@ -86,6 +102,7 @@ import { STable, Ellipsis } from '@/components'
 import { getPurchaseOrderPage2, deletePurchaseOrder2, getPurchaseOrderInfo, pushPurchaseOrder, wastePurchaseOrder, getPurchaseOrderList } from '@/api/purchase/purchase-order'
 import BaseForm from './modules/BaseForm.vue'
 import Detail from './modules/Detail.vue'
+import MargeModal from './modules/MargeModal.vue'
 import AddSpareForm from '@/views/store/sparestore/modules/AddSpareForm'
 export default {
   name: 'PurchaseOrderPage',
@@ -94,7 +111,8 @@ export default {
     Ellipsis,
     BaseForm,
     AddSpareForm,
-    Detail
+    Detail,
+    MargeModal
   },
   data () {
     return {
@@ -240,7 +258,8 @@ export default {
       options: {
         alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
         rowSelection: {
-          selectedRowKeys: this.selectedRowKeys
+          selectedRowKeys: this.selectedRowKeys,
+          onChange: this.onSelectChange
         }
       },
       optionAlertShow: false,
@@ -263,6 +282,7 @@ export default {
           alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
           rowSelection: {
             selectedRowKeys: this.selectedRowKeys,
+            onChange: this.onSelectChange,
             getCheckboxProps: record => ({
               props: {
                 disabled: false,
@@ -280,9 +300,17 @@ export default {
         this.optionAlertShow = false
       }
     },
+    onSelectChange (selectedRowKeys, selectedRows) {
+      this.selectedRowKeys = selectedRowKeys
+      this.selectedRows = selectedRows
+    },
+    handleMerge () {
+      this.$refs.margeModal.base(null, this.selectedRows)
+    },
     handleOk () {
       this.visible = true
-      this.$refs.table.refresh()
+      this.$refs.table.clearSelected()
+      this.$refs.table.refresh(true)
     },
     resetSearchForm () {
       this.queryParam = {

+ 250 - 0
src/views/purchase/purchase-order-page/modules/MargeModal.vue

@@ -0,0 +1,250 @@
+<template>
+  <a-modal
+    :title="title"
+    :width="1200"
+    :visible="visible"
+    :confirmLoading="confirmLoading"
+    @cancel="handleCancel"
+  >
+    <a-form :form="form">
+      <row-list :col="1" v-show="false">
+        <row-item>
+          <a-form-item>
+            <a-input v-decorator="['id']" type="hidden"/>
+          </a-form-item>
+        </row-item>
+      </row-list>
+      <row-list :col="1">
+        <row-item>
+          <a-form-item
+            label="合并采购单名称"
+            :labelCol="BaseTool.Constant.labelCol2"
+            :wrapperCol="BaseTool.Constant.wrapperCol2">
+            <a-input v-decorator="['title',{rules: [{required: true, message: '合并采购单名称不能为空'}]}]" />
+          </a-form-item>
+        </row-item>
+      </row-list>
+    </a-form>
+    <a-table
+      bordered
+      :data-source="data"
+      :columns="columns"
+      tableLayout="auto"
+      rowKey="id"
+      :scroll="{ x: 1500 }"
+    >
+      <template #status="text">
+        <badge :text="BaseTool.Object.getField(statusMap,text)" :status="DictCache.COLOR.LONG_YAN_PURCHASE_ORDER_STATUS[text]"/>
+      </template>
+      <span slot="action" slot-scope="record">
+        <template>
+          <a-popconfirm title="是否要删除该条数据?" @confirm="handleDelOne(record)">
+            <a>删除</a>
+          </a-popconfirm>
+        </template>
+      </span>
+    </a-table>
+    <template slot="footer">
+      <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
+    </template>
+  </a-modal>
+</template>
+
+<script>
+import pick from 'lodash.pick'
+import { mergePurchase, updatamergePurchase } from '@/api/purchase/purchase-order'
+export default {
+  data () {
+    return {
+      visible: false,
+      title: '',
+      form: this.$form.createForm(this),
+      confirmLoading: false,
+      data: [],
+      cptcodeMap: {},
+      cbustypeMap: {},
+      typeMap: {},
+      columns: [
+        {
+          title: '序号',
+          dataIndex: 'index',
+          checked: true,
+          width: 70,
+          customRender: (text, record, index) => {
+            return index + 1
+          }
+        },
+        {
+          title: '计划类型',
+          dataIndex: 'type',
+          checked: true,
+          width: 100,
+          customRender: (text, record, index) => {
+            return this.BaseTool.Table.getMapText(this.typeMap, text)
+          }
+        },
+        {
+          title: '采购类型',
+          dataIndex: 'cptcode',
+          checked: true,
+          width: 130,
+          customRender: (text, record, index) => {
+            return this.BaseTool.Table.getMapText(this.cptcodeMap, text)
+          }
+        },
+        {
+          title: '业务类型',
+          dataIndex: 'cbustype',
+          checked: true,
+          width: 150,
+          customRender: (text, record, index) => {
+            return this.BaseTool.Table.getMapText(this.cbustypeMap, text)
+          }
+        },
+        {
+          title: '关联设备',
+          dataIndex: 'positionNo',
+          checked: true,
+          width: 150
+        },
+        {
+          title: '采购数量',
+          dataIndex: 'totalNum',
+          checked: true,
+          width: 150
+        },
+        {
+          title: '请购人员',
+          dataIndex: 'createdUserName',
+          checked: true,
+          width: 150
+        },
+        {
+          title: '用友单号',
+          checked: true,
+          width: 100,
+          dataIndex: 'yongYouId'
+        },
+        {
+          title: '需求日期',
+          dataIndex: 'needDate',
+          checked: true,
+          width: 150
+        },
+        {
+          title: '计划到货日期',
+          dataIndex: 'planGetDate',
+          checked: true,
+          width: 150
+        },
+        {
+          title: '申请时间',
+          dataIndex: 'updateTime',
+          checked: true,
+          width: 150
+        },
+        {
+          title: '请购原因',
+          checked: true,
+          width: 100,
+          dataIndex: 'cmemo'
+        },
+        {
+          title: '错误消息',
+          checked: true,
+          width: 100,
+          dataIndex: 'errorMessage'
+        },
+        {
+          title: '操作',
+          key: 'action',
+          width: '200px',
+          fixed: 'right',
+          checked: true,
+          align: 'center',
+          scopedSlots: { customRender: 'action' }
+        }
+      ]
+
+    }
+  },
+  created () {
+    // 下拉框map
+    this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LONG_YAN_PURCHASE_TYPE)
+    this.cptcodeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LONG_YAN_PURCHASE_ORDER_PLAN_TYPE)
+    this.cbustypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LONG_YAN_PURCHASE_BUSINESS_TYPE)
+  },
+  methods: {
+    base (record, list = []) {
+      this.visible = true
+      this.data = list
+      if (this.BaseTool.Object.isBlank(record)) {
+        this.title = '新增合并采购单'
+        return
+      }
+      this.title = '编辑合并采购单'
+      // this.data = record.detailVOS
+      const { form: { setFieldsValue } } = this
+      this.$nextTick(() => {
+        setFieldsValue(Object.assign(pick(record, [
+          'id'
+        ])))
+      })
+    },
+    save () {
+      const { form: { validateFieldsAndScroll } } = this
+      this.confirmLoading = true
+      validateFieldsAndScroll((errors, values) => {
+        if (errors) {
+          Object.values(errors).map(item => {
+            this.$message.error(item.errors[0].message)
+          })
+          this.confirmLoading = false
+          return
+        }
+        values.purchaseOrderStr = this.data.map(item => {
+          return pick(item, [
+            'id',
+            'sbId',
+            'type',
+            'oldOrNew',
+            'projectId',
+            'positionNo',
+            'cptcode',
+            'remark',
+            'cdepcode',
+            'cbustype',
+            'planGetDate',
+            'needDate'
+          ])
+        }).join(',')
+        if (values.id) {
+          updatamergePurchase(values).then(res => {
+            this.$message.success('修改成功!')
+            this.handleCancel()
+          })
+        } else {
+          mergePurchase(values).then(res => {
+            this.$message.success('创建成功!')
+            this.handleCancel()
+          })
+        }
+      })
+    },
+    handleDelOne (record) {
+      const data = [...this.data]
+      this.data = data.filter(item => record.id !== item.id)
+    },
+    handleCancel (values) {
+      this.visible = false
+      this.data = []
+      this.form.resetFields()
+      this.$emit('ok', values)
+    }
+  }
+}
+</script>
+
+<style>
+
+</style>