linwenxin 4 ヶ月 前
コミット
32e3811ba2

+ 65 - 0
src/api/purchasePlanAdjustment.js

@@ -0,0 +1,65 @@
+import request, { postBlob, getBlob, handleImport } from '@/utils/request'
+
+export function goodsAdjustPlanList(data) {
+  return request({
+    url: `/goods/adjust/plan/list?moduleId=${data.moduleId}`,
+    method: 'post',
+    data
+  })
+}
+
+export function goodsAdjustPlanListExport(data, name) {
+  return postBlob({
+    url: '/goods/adjust/plan/list/export',
+    data,
+    name
+  })
+}
+
+export function goodsAdjustPlanAdd(data) {
+  return request({
+    url: `/goods/adjust/plan/add`,
+    method: 'post',
+    data
+  })
+}
+
+export function goodsAdjustPlanUpdate(data) {
+  return request({
+    url: `/goods/adjust/plan/update`,
+    method: 'post',
+    data
+  })
+}
+
+export function goodsAdjustPlanSubmit(data) {
+  return request({
+    url: '/goods/adjust/plan/submit',
+    method: 'post',
+    params: data
+  })
+}
+
+export function goodsAdjustPlanDetail(params) {
+  return request({
+    url: '/goods/adjust/plan/detail',
+    method: 'post',
+    params: params
+  })
+}
+
+export function goodsAdjustPlanConfirm(params) {
+  return request({
+    url: '/goods/adjust/plan/confirm',
+    method: 'post',
+    params: params
+  })
+}
+
+export function goodsAdjustPlanDel(params) {
+  return request({
+    url: '/goods/adjust/plan/del',
+    method: 'post',
+    params: params
+  })
+}

+ 314 - 0
src/views/mallManagement/purchaseScheduleManagement/purchasePlanAdjustment/index.vue

@@ -0,0 +1,314 @@
+<template>
+  <template-page
+    ref="pageRef"
+    :get-list="getList"
+    :table-attributes="tableAttributes"
+    :table-events="tableEvents"
+    :options-evens-group="optionsEvensGroup"
+    :moreParameters="moreParameters"
+    :column-parsing="columnParsing"
+    :exportList="exportList"
+    :operation="operation()"
+  >
+    <div class="cartographer_big">
+      <el-dialog
+        :title="formDialogTitles[formDialogType]"
+        width="100%"
+        :modal="false"
+        :visible.sync="formDialog"
+        :before-close="handleClose"
+      >
+        <zj-page-container>
+          <zj-page-fill>
+            <div style="box-sizing: border-box; padding: 20px 20px 0 20px">
+              <zj-form-container ref="formRef" :form-data="formData" :form-attributes="{ size: 'mini' }">
+                <zj-form-module title="单据信息" label-width="100px" :form-data="formData" :form-items="formItems">
+                </zj-form-module>
+                <zj-form-module title="商品信息" label-width="100px" :form-data="formData" :form-items="formItems2">
+                </zj-form-module>
+              </zj-form-container>
+            </div>
+          </zj-page-fill>
+          <div style="text-align: right; box-sizing: border-box; padding: 16px 20px">
+            <el-button v-if="formDialogType == 0" size="mini" type="primary" @click="save">保存</el-button>
+            <el-button v-if="formDialogType == 1" size="mini" type="primary" @click="save2">保存</el-button>
+            <el-button v-if="formDialogType == 1" size="mini" type="primary" @click="submit">提交</el-button>
+            <el-button v-if="formDialogType == 3" size="mini" type="primary" @click="examine('OK')">审核通过</el-button>
+            <el-button v-if="formDialogType == 3" size="mini" type="primary" @click="examine('FAIL')"
+              >审核驳回</el-button
+            >
+          </div>
+        </zj-page-container>
+      </el-dialog>
+    </div>
+  </template-page>
+</template>
+
+<script>
+import TemplatePage from '@/components/template/template-page-1.vue'
+import import_mixin from '@/components/template/import_mixin.js'
+import operation_mixin from '@/components/template/operation_mixin.js'
+import {
+  goodsPlanItemList,
+  goodsPlanListExport,
+  goodsPlanAdd,
+  goodsPlanUpdate,
+  goodsPlanSubmit,
+  goodsPlanDetail,
+  goodsPlanConfirm,
+  goodsPlanDel
+} from '@/api/purchaseSchedule.js'
+import form_ty from './mixins/common_form'
+import storage_table from './mixins/storage_table'
+import storage_goods from './mixins/storage_goods'
+import { delayPerform, firstPerform, intervalPerform, passivePerform, queuePerform } from 'js-perform-lock'
+export default {
+  components: { TemplatePage },
+  mixins: [import_mixin, operation_mixin, form_ty, storage_table, storage_goods],
+  data() {
+    return {
+      // 表格属性
+      tableAttributes: {
+        // 启用勾选列
+        selectColumn: false
+      },
+      // 表格事件
+      tableEvents: {
+        'selection-change': this.selectionChange
+      },
+      // 勾选选中行
+      recordSelected: [],
+      /** 表单变量 */
+      formDialogType: 0,
+      formDialogTitles: ['新增', '编辑', '详情', '审核'],
+      formDialog: false,
+      formData: {
+        fileUrl: [],
+        companyWechatId: '',
+        companyWechatName: '',
+        examineBy: '',
+        examineTime: '',
+        goodsPlanId: '',
+        id: '',
+        items: [],
+        remark: '',
+        status: '',
+        submitBy: '',
+        submitTime: '',
+        updateBy: '',
+        updateTime: '',
+        venderId: '',
+        venderName: ''
+      },
+      logs: []
+    }
+  },
+  computed: {
+    // 事件组合
+    optionsEvensGroup() {
+      return [
+        [
+          [
+            this.optionsEvensAuth('add', {
+              click: () => {
+                this.openForm()
+                this.formDialog = true
+              }
+            })
+          ]
+        ]
+      ]
+    },
+    // 更多参数
+    moreParameters() {
+      return []
+    }
+  },
+  methods: {
+    tishicuowu: new delayPerform(500).refactor(function (/**可接收参数**/) {
+      if (this.logs) {
+        var logs = Array.from(
+          new Set(
+            JSON.parse(JSON.stringify(this.logs)).map(item => {
+              return `${item.index !== undefined ? '第' + (item.index + 1) + '行:' : ''}${item.errMsg}`
+            })
+          )
+        )
+        this.logs = []
+        this.$message({
+          dangerouslyUseHTMLString: true,
+          type: 'warning',
+          message: logs.join('<div/>'),
+          duration: 5000
+        })
+      }
+    }),
+    // 列表请求函数
+    getList(p, cb) {
+      return goodsPlanItemList(p)
+    },
+    // 列表导出函数
+    exportList: goodsPlanListExport,
+    // 表格列解析渲染数据更改
+    columnParsing(item, defaultData) {
+      return defaultData
+    },
+    // 监听勾选变化
+    selectionChange(data) {
+      this.recordSelected = data
+    },
+    // 打开创建弹窗
+    openForm() {
+      this.isEditIndex = -1
+      this.getGysList()
+      this.getBaseList()
+    },
+    // 打开详情弹窗
+    openDetailForm(row, type) {
+      goodsPlanDetail({ id: row.id }).then(res => {
+        Object.assign(this.formData, res.data, {
+          fileUrl: res.data.fileUrl ? [{ url: res.data.fileUrl }] : [],
+          items: res.data.items.map(item => ({ ...item, details: {} }))
+        })
+        this.formDialogType = type
+        this.openForm()
+        this.formDialog = true
+      })
+    },
+    // 关闭弹窗
+    handleClose() {
+      this.$refs?.formRef?.resetFields()
+      this.$data.formData = this.$options.data().formData
+      this.formDialog = false
+      this.formDialogType = 0
+    },
+    // 操作按钮
+    operation() {
+      return this.operationBtn({
+        edit: {
+          conditions: ({ row, index, column }) => {
+            return row.status == 'SAVE'
+          },
+          click: ({ row, index, column }) => {
+            this.openDetailForm(row, 1)
+          }
+        },
+        del: {
+          prompt: '是否确定删除',
+          conditions: ({ row, index, column }) => {
+            return row.status == 'SAVE'
+          },
+          click: ({ row, index, column }) => {
+            goodsPlanDel({
+              id: row.id
+            }).then(res => {
+              this.$message({
+                type: 'success',
+                message: '删除成功'
+              })
+              this.$refs.pageRef.refreshList()
+            })
+          }
+        },
+        details: {
+          click: ({ row, index, column }) => {
+            this.openDetailForm(row, 2)
+          }
+        },
+        examine: {
+          conditions: ({ row, index, column }) => {
+            return row.status == 'WAIT'
+          },
+          click: ({ row, index, column }) => {
+            this.openDetailForm(row, 3)
+          }
+        }
+      })
+    },
+    // 保存
+    save() {
+      this.$refs.formRef.validateField(this.getVfyKey(this.isEditIndex), (valid, invalidFields, errLabels) => {
+        if (valid && this.eidtItems()) {
+          goodsPlanAdd({
+            ...this.formData,
+            items: this.formData.items.map((item, index) => ({ ...item, index: index + 1 })),
+            fileUrl: this.formData.fileUrl.map(item => item.url).join(',')
+          }).then(res => {
+            this.$message({
+              type: 'success',
+              message: '保存成功'
+            })
+            this.handleClose()
+            this.$refs.pageRef.refreshList()
+          })
+        }
+      })
+    },
+    save2() {
+      this.$refs.formRef.validateField(this.getVfyKey(this.isEditIndex), (valid, invalidFields, errLabels) => {
+        if (valid && this.eidtItems()) {
+          goodsPlanUpdate({
+            ...this.formData,
+            items: this.formData.items.map((item, index) => ({ ...item, index: index + 1 })),
+            fileUrl: this.formData.fileUrl.map(item => item.url).join(',')
+          }).then(res => {
+            this.$message({
+              type: 'success',
+              message: '保存成功'
+            })
+            this.handleClose()
+            this.$refs.pageRef.refreshList()
+          })
+        }
+      })
+    },
+    // 提交
+    submit() {
+      this.$refs.formRef.validateField(this.getVfyKey(this.isEditIndex), (valid, invalidFields, errLabels) => {
+        if (valid && this.eidtItems()) {
+          goodsPlanUpdate({
+            ...this.formData,
+            items: this.formData.items.map((item, index) => ({ ...item, index: index + 1 })),
+            fileUrl: this.formData.fileUrl.map(item => item.url).join(',')
+          }).then(res => {
+            goodsPlanSubmit({
+              id: this.formData.id
+            }).then(res => {
+              this.$message({
+                type: 'success',
+                message: '提交成功'
+              })
+              this.handleClose()
+              this.$refs.pageRef.refreshList()
+            })
+          })
+        }
+      })
+    },
+    // 审核
+    examine(type) {
+      goodsPlanConfirm({
+        id: this.formData.id,
+        statusEnum: type
+      }).then(res => {
+        this.$message({
+          type: 'success',
+          message: '操作成功'
+        })
+        this.handleClose()
+        this.$refs.pageRef.refreshList()
+      })
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.tab {
+  padding: 20px 20px 0 20px;
+}
+
+::v-deep .teshudeshangchuananniu {
+  color: #409eff !important;
+}
+</style>

+ 257 - 0
src/views/mallManagement/purchaseScheduleManagement/purchasePlanAdjustment/mixins/common_form.js

@@ -0,0 +1,257 @@
+import { required, diyRequired } from '@/components/template/rules_verify.js'
+import { listPageV2 } from '@/api/auxiliaryFittings/supplier'
+import { goodsPlanList, goodsAdjustPlanDetail } from '@/api/purchaseSchedule.js'
+import ImageUpload from '@/components/file-upload'
+
+export default {
+  data() {
+    return {
+      gysList: [],
+      cgrkOrder: []
+    }
+  },
+  computed: {
+    formItems() {
+      return [
+        {
+          md: 24,
+          isShow: true,
+          name: 'slot-component',
+          formItemAttributes: {
+            label: '',
+            prop: '',
+            'label-width': '0px'
+          },
+          render: (h, { props, onInput }) => {
+            var { value } = props
+            return (
+              <div>
+                <el-descriptions
+                  border
+                  title=""
+                  column={4}
+                  colon={false}
+                  labelStyle={{ width: '8%' }}
+                  contentStyle={{ width: '17%' }}
+                >
+                  <el-descriptions-item label="单据状态">
+                    {{ SAVE: '保存', WAIT: '待审核', OK: '通过', FAIL: '失败' }[this.formData.status] || ''}
+                  </el-descriptions-item>
+                  <el-descriptions-item label="单据编号">{this.formData.id || ''}</el-descriptions-item>
+                  <el-descriptions-item label="所属商户" contentStyle={{ width: '42%' }}>
+                    {JSON.parse(localStorage.getItem('greemall_user')).companyName}
+                  </el-descriptions-item>
+                </el-descriptions>
+                <el-descriptions
+                  border
+                  title=""
+                  column={3}
+                  colon={false}
+                  labelStyle={{ width: '8%' }}
+                  contentStyle={{ width: '42%' }}
+                  style="margin-top:-1px"
+                >
+                  <el-descriptions-item label="*供应商名称">
+                    <div class="redbordererr">
+                      <el-form-item
+                        label=""
+                        lebel-width="0px"
+                        prop={`venderId`}
+                        rules={[
+                          diyRequired.bind(this)((rule, value) => {
+                            if (this.logs) {
+                              this.logs.push({ errMsg: `*供应商名称不能为空` })
+                            }
+                            this?.tishicuowu?.()
+                            return new Error('必须填写')
+                          })
+                        ]}
+                      >
+                        <el-select
+                          style="width:100%"
+                          value={this.formData.venderId}
+                          onInput={val => {
+                            this.formData.venderId = val
+                          }}
+                          placeholder="请选择"
+                          disabled={!!~['WAIT', 'OK', 'FAIL'].indexOf(this.formData.status)}
+                          onChange={val => {
+                            if (val) {
+                              this.formData['venderName'] = this.gysList.find(item => item.venderId == val).venderName
+                            } else {
+                              this.formData['venderName'] = ''
+                            }
+                            this.cgrkOrder = []
+                            this.getGysList()
+                          }}
+                        >
+                          {this.gysList.map(item => (
+                            <el-option key={item.venderId} label={item.venderName} value={item.venderId}></el-option>
+                          ))}
+                        </el-select>
+                      </el-form-item>
+                    </div>
+                  </el-descriptions-item>
+                  <el-descriptions-item label="采购计划单">
+                    <div class="redbordererr">
+                      <el-form-item
+                        label=""
+                        lebel-width="0px"
+                        prop={`goodsPlanId`}
+                        rules={[
+                          diyRequired.bind(this)((rule, value) => {
+                            if (this.logs) {
+                              this.logs.push({ errMsg: `*goodsPlanId不能为空` })
+                            }
+                            this?.tishicuowu?.()
+                            return new Error('必须填写')
+                          })
+                        ]}
+                      >
+                        <el-select
+                          style="width:100%"
+                          value={this.formData.goodsPlanId}
+                          onInput={val => {
+                            this.formData.goodsPlanId = val
+                          }}
+                          placeholder="请选择"
+                          disabled={!!~['WAIT', 'OK', 'FAIL'].indexOf(this.formData.status)}
+                          onChange={val => {
+                            this.formData.items = []
+                            if (val) {
+                              goodsAdjustPlanDetail({ id: val }).then(res => {
+                                this.formData.items = res.data.items.map(item => ({
+                                  adjustQty: '',
+                                  amount: item.amount,
+                                  brandId: item.brandId,
+                                  brandName: item.brandName,
+                                  factoryNo: item.factoryNo,
+                                  goodsMaterialId: item.goodsMaterialId,
+                                  goodsMaterialName: item.goodsMaterialName,
+                                  goodsPlanItemId: item.goodsPlanItemId,
+                                  inStockQty: item.inStockQty,
+                                  insideQty: item.insideQty,
+                                  mainId: item.mainId,
+                                  mainName: item.mainName,
+                                  outQty: item.outQty,
+                                  partsQty: item.partsQty,
+                                  price: item.price,
+                                  qty: item.qty,
+                                  seriesName: item.seriesName,
+                                  smallId: item.smallId,
+                                  smallName: item.smallName,
+                                  specsName: item.specsName,
+                                  surplusQty: item.surplusQty,
+                                  unit: item.unit,
+                                  details: {}
+                                }))
+                              })
+                            }
+                          }}
+                        >
+                          {this.cgrkOrder.map(item => (
+                            <el-option
+                              key={item.id}
+                              label={`${item.id} | 销售金额:${item.totalAmount || '-'} | 入库时间:${
+                                item.examineTime || '-'
+                              }`}
+                              value={item.id}
+                            ></el-option>
+                          ))}
+                        </el-select>
+                      </el-form-item>
+                    </div>
+                  </el-descriptions-item>
+                </el-descriptions>
+                <el-descriptions
+                  border
+                  title=""
+                  column={4}
+                  colon={false}
+                  labelStyle={{ width: '8%' }}
+                  contentStyle={{ width: '17%' }}
+                  style="margin-top:-1px"
+                >
+                  <el-descriptions-item label="制单人">{this.formData.createBy}</el-descriptions-item>
+                  <el-descriptions-item label="制单时间">{this.formData.createTime}</el-descriptions-item>
+                  <el-descriptions-item label="审核人">{this.formData.examineBy}</el-descriptions-item>
+                  <el-descriptions-item label="审核时间">{this.formData.examineTime}</el-descriptions-item>
+                </el-descriptions>
+                <el-descriptions
+                  border
+                  title=""
+                  column={4}
+                  colon={false}
+                  labelStyle={{ width: '8%' }}
+                  contentStyle={{ width: '17%' }}
+                  style="margin-top:-1px"
+                >
+                  <el-descriptions-item label="备注" contentStyle={{ width: '92%' }}>
+                    <el-input
+                      type="textarea"
+                      placeholder="请输入内容"
+                      value={this.formData.remark}
+                      onInput={val => {
+                        this.formData.remark = val
+                      }}
+                      maxlength="200"
+                      show-word-limit
+                      autosize={{ minRows: 2, maxRows: 4 }}
+                      disabled={!!~['WAIT', 'OK', 'FAIL'].indexOf(this.formData.status)}
+                    ></el-input>
+                  </el-descriptions-item>
+                </el-descriptions>
+                <el-descriptions
+                  border
+                  title=""
+                  column={4}
+                  colon={false}
+                  labelStyle={{ width: '8%' }}
+                  contentStyle={{ width: '17%' }}
+                  style="margin-top:-1px"
+                >
+                  <el-descriptions-item label="附件" contentStyle={{ width: '92%' }}>
+                    <ImageUpload
+                      fileList={this.formData.fileUrl}
+                      uid="imgSrc666_materials_drawing_images"
+                      limit={1}
+                      isEdit={!~['WAIT', 'OK', 'FAIL'].indexOf(this.formData.status)}
+                      fileType={['image']}
+                    />
+                  </el-descriptions-item>
+                </el-descriptions>
+              </div>
+            )
+          }
+        }
+      ]
+    }
+  },
+  methods: {
+    // 获取供应商列表
+    getGysList() {
+      if (this.formData.venderId) {
+        goodsPlanList({
+          pageNum: 1,
+          pageSize: -1,
+          params: [
+            { param: 'a.vender_id', compare: '=', value: this.formData.venderId },
+            { param: 'a.status', compare: '=', value: 'OK' }
+          ]
+        }).then(res => {
+          this.cgrkOrder = res.data.records
+        })
+      }
+      listPageV2({
+        pageNum: 1,
+        pageSize: -1,
+        params: [
+          { param: 'a.status', compare: '=', value: 'ON' },
+          { param: 'a.vender_type', compare: 'like', value: '商品' }
+        ]
+      }).then(res => {
+        this.gysList = res.data.records
+      })
+    }
+  }
+}

+ 566 - 0
src/views/mallManagement/purchaseScheduleManagement/purchasePlanAdjustment/mixins/storage_goods.js

@@ -0,0 +1,566 @@
+import { required, diyRequired } from '@/components/template/rules_verify.js'
+import { getBrandList } from '@/api/miniapp'
+import { getClassifyList } from '@/api/goods'
+import { goodsMaterialList } from '@/api/commercialMaterial.js'
+import { goodsPurchaseItemImportCode, goodsPurchaseDetail } from '@/api/goodsPurchasedStored.js'
+import { goodsMaterialDetail } from '@/api/commercialMaterial.js'
+export default {
+  data() {
+    return {
+      brandList: [],
+      ClassifyList: [],
+      goodsMaterialList: []
+    }
+  },
+  computed: {
+    storage_goods() {
+      return [
+        {
+          columnAttributes: {
+            label: '*品牌',
+            prop: 'brandId',
+            propName: 'brandName',
+            width: 160
+          },
+          render: (h, { row, column, index }) => {
+            return this.isEditIndex == index ? (
+              <div class="redbordererr">
+                <el-form-item
+                  label=""
+                  lebel-width="0px"
+                  prop={`items.${index}.${column.columnAttributes.prop}`}
+                  rules={[
+                    diyRequired.bind(this)((rule, value) => {
+                      if (this.logs) {
+                        this.logs.push({ index: index, errMsg: `${column.columnAttributes.label}不能为空` })
+                      }
+                      this?.tishicuowu?.()
+                      return new Error('必须填写')
+                    })
+                  ]}
+                >
+                  <el-select
+                    value={row[column.columnAttributes.prop]}
+                    onInput={val => {
+                      row[column.columnAttributes.prop] = val
+                    }}
+                    onChange={val => {
+                      this.shanchujichu(row, 0)
+                      if (val) {
+                        row[column.columnAttributes.propName] = this.brandList.find(item => item.id == val).brandName
+                      } else {
+                        row[column.columnAttributes.propName] = ''
+                      }
+                    }}
+                    placeholder="请选择"
+                    disabled={true}
+                  >
+                    {this.brandList.map((item, index_) => (
+                      <el-option key={index_} label={item.brandName} value={item.id}></el-option>
+                    ))}
+                  </el-select>
+                </el-form-item>
+              </div>
+            ) : (
+              <div style="padding:0 6px">{row[column.columnAttributes.propName]}</div>
+            )
+          }
+        },
+        {
+          columnAttributes: {
+            label: '*商品大类',
+            prop: 'mainId',
+            propName: 'mainName',
+            width: 160
+          },
+          render: (h, { row, column, index }) => {
+            return this.isEditIndex == index ? (
+              <div class="redbordererr">
+                <el-form-item
+                  label=""
+                  lebel-width="0px"
+                  prop={`items.${index}.${column.columnAttributes.prop}`}
+                  rules={[
+                    diyRequired.bind(this)((rule, value) => {
+                      if (this.logs) {
+                        this.logs.push({ index: index, errMsg: `${column.columnAttributes.label}不能为空` })
+                      }
+                      this?.tishicuowu?.()
+                      return new Error('必须填写')
+                    })
+                  ]}
+                >
+                  <el-select
+                    value={row[column.columnAttributes.prop]}
+                    onInput={val => {
+                      row[column.columnAttributes.prop] = val
+                    }}
+                    onChange={val => {
+                      this.shanchujichu(row, 1)
+                      if (val) {
+                        row[column.columnAttributes.propName] = this.ClassifyList.find(
+                          item => item.categoryId == val
+                        ).name
+                      } else {
+                        row[column.columnAttributes.propName] = ''
+                      }
+                    }}
+                    placeholder="请选择"
+                    disabled={true}
+                  >
+                    {this.ClassifyList.map((item, index_) => (
+                      <el-option key={index_} label={item.name} value={item.categoryId}></el-option>
+                    ))}
+                  </el-select>
+                </el-form-item>
+              </div>
+            ) : (
+              <div style="padding:0 6px">{row[column.columnAttributes.propName]}</div>
+            )
+          }
+        },
+        {
+          columnAttributes: {
+            label: '*商品小类',
+            prop: 'smallId',
+            propName: 'smallName',
+            width: 160
+          },
+          render: (h, { row, column, index }) => {
+            return this.isEditIndex == index ? (
+              <div class="redbordererr">
+                <el-form-item
+                  label=""
+                  lebel-width="0px"
+                  prop={`items.${index}.${column.columnAttributes.prop}`}
+                  rules={[
+                    diyRequired.bind(this)((rule, value) => {
+                      if (this.logs) {
+                        this.logs.push({ index: index, errMsg: `${column.columnAttributes.label}不能为空` })
+                      }
+                      this?.tishicuowu?.()
+                      return new Error('必须填写')
+                    })
+                  ]}
+                >
+                  <el-select
+                    value={row[column.columnAttributes.prop]}
+                    onInput={val => {
+                      row[column.columnAttributes.prop] = val
+                    }}
+                    onChange={val => {
+                      this.shanchujichu(row, 2)
+                      if (val) {
+                        row[column.columnAttributes.propName] = (
+                          this.ClassifyList.find(item => item.categoryId == row.mainId)?.children || []
+                        ).find(item => item.categoryId == val).name
+                      } else {
+                        row[column.columnAttributes.propName] = ''
+                      }
+                    }}
+                    placeholder="请选择"
+                    disabled={true}
+                  >
+                    {(this.ClassifyList.find(item => item.categoryId == row.mainId)?.children || []).map(
+                      (item, index_) => (
+                        <el-option key={index_} label={item.name} value={item.categoryId}></el-option>
+                      )
+                    )}
+                  </el-select>
+                </el-form-item>
+              </div>
+            ) : (
+              <div style="padding:0 6px">{row[column.columnAttributes.propName]}</div>
+            )
+          }
+        },
+        {
+          columnAttributes: {
+            label: '*商品名称',
+            prop: 'goodsMaterialId',
+            propName: 'goodsMaterialName',
+            width: 160
+          },
+          render: (h, { row, column, index }) => {
+            return this.isEditIndex == index ? (
+              <div class="redbordererr">
+                <el-form-item
+                  label=""
+                  lebel-width="0px"
+                  prop={`items.${index}.${column.columnAttributes.prop}`}
+                  rules={[
+                    diyRequired.bind(this)((rule, value) => {
+                      if (this.logs) {
+                        this.logs.push({ index: index, errMsg: `${column.columnAttributes.label}不能为空` })
+                      }
+                      this?.tishicuowu?.()
+                      return new Error('必须填写')
+                    })
+                  ]}
+                >
+                  <el-select
+                    value={row[column.columnAttributes.prop]}
+                    onInput={val => {
+                      row[column.columnAttributes.prop] = val
+                    }}
+                    onChange={val => {
+                      this.shanchujichu(row, 3)
+                      if (val) {
+                        var data = this.goodsMaterialList
+                          .filter(
+                            item =>
+                              item.brandId === row.brandId && item.mainId === row.mainId && item.smallId === row.smallId
+                          )
+                          .find(item => item.id == val)
+                        row[column.columnAttributes.propName] = data?.goodsName
+                        this.getGoodsDetl(data, res => {
+                          if (!!~[0, 1].indexOf(this.formDialogType)) {
+                            row['specsName'] = res?.specsName
+                            row['unit'] = res?.unit
+                            row['insideQty'] =
+                              res.items
+                                .filter(item => item.type === 'INSIDE')
+                                .map(item => item.qty)
+                                .reduce((accumulator, currentValue) => accumulator + currentValue, 0) * Number(row?.qty)
+                            row['outQty'] =
+                              res.items
+                                .filter(item => item.type === 'OUT')
+                                .map(item => item.qty)
+                                .reduce((accumulator, currentValue) => accumulator + currentValue, 0) * Number(row?.qty)
+                            row['partsQty'] =
+                              res.items
+                                .filter(item => item.type === 'PARTS')
+                                .map(item => item.qty)
+                                .reduce((accumulator, currentValue) => accumulator + currentValue, 0) * Number(row?.qty)
+                          }
+                        })
+                      } else {
+                        row[column.columnAttributes.propName] = ''
+                        row['specsName'] = ''
+                        row['unit'] = ''
+                        row['insideQty'] = ''
+                        row['outQty'] = ''
+                        row['partsQty'] = ''
+                      }
+                    }}
+                    filterable={true}
+                    placeholder="请选择"
+                    disabled={true}
+                  >
+                    {this.goodsMaterialList
+                      .filter(
+                        item =>
+                          item.brandId === row.brandId && item.mainId === row.mainId && item.smallId === row.smallId
+                      )
+                      .map((item, index_) => (
+                        <el-option key={index_} label={item.goodsName} value={item.id}></el-option>
+                      ))}
+                  </el-select>
+                </el-form-item>
+              </div>
+            ) : (
+              <div style="padding:0 6px">{row[column.columnAttributes.propName]}</div>
+            )
+          }
+        },
+        {
+          columnAttributes: {
+            label: '规格型号',
+            prop: 'specsName',
+            width: 120
+          }
+        },
+        {
+          columnAttributes: {
+            label: '单位',
+            prop: 'unit'
+          },
+          render: (h, { row, column, index }) => {
+            return <div style="padding:0 6px">{{ C: '整套', I: '单个' }[row[column.columnAttributes.prop]] || ''}</div>
+          }
+        },
+        {
+          columnAttributes: {
+            label: '计划采购数量',
+            prop: 'qty',
+            width: 120
+          }
+        },
+        {
+          columnAttributes: {
+            label: '*新采购数量',
+            prop: 'adjustQty',
+            width: 160
+          },
+          render: (h, { row, column, index }) => {
+            return this.isEditIndex == index ? (
+              <div class="redbordererr">
+                <el-form-item
+                  label=""
+                  lebel-width="0px"
+                  prop={`items.${index}.${column.columnAttributes.prop}`}
+                  rules={[
+                    diyRequired.bind(this)((rule, value) => {
+                      if (this.logs) {
+                        this.logs.push({ index: index, errMsg: `${column.columnAttributes.label}不能为空` })
+                      }
+                      this?.tishicuowu?.()
+                      return new Error('必须填写')
+                    })
+                  ]}
+                >
+                  <el-input
+                    value={row[column.columnAttributes.prop]}
+                    onInput={val => {
+                      row[column.columnAttributes.prop] = val <= 0 ? 0 : Number(val)
+                    }}
+                    type="number"
+                    placeholder="请输入"
+                  ></el-input>
+                </el-form-item>
+              </div>
+            ) : (
+              <div style="padding:0 6px">{row[column.columnAttributes.prop]}</div>
+            )
+          }
+        },
+        {
+          columnAttributes: {
+            label: '已入库数量',
+            prop: 'inStockQty'
+          }
+        },
+        {
+          columnAttributes: {
+            label: '剩余数量',
+            prop: 'surplusQty'
+          }
+        },
+        ...(() => {
+          if (this.formDialogType < 2 && !~['WAIT', 'OK', 'FAIL'].indexOf(this.formData.status)) {
+            return [
+              {
+                columnAttributes: {
+                  label: '操作',
+                  fixed: 'right',
+                  width: 140
+                },
+                render: (h, { row, column, index }) => {
+                  return (
+                    <div style="padding:0 6px" class="operation-btns">
+                      {[
+                        this.isEditIndex == index ? (
+                          <el-button
+                            type="text"
+                            onClick={() => {
+                              this.$refs.formRef.validateField(
+                                this.getVfyKey(this.isEditIndex),
+                                (valid, invalidFields, errLabels) => {
+                                  if (valid && this.eidtItems()) {
+                                    this.isEditIndex = -1
+                                  }
+                                }
+                              )
+                            }}
+                          >
+                            保存
+                          </el-button>
+                        ) : null,
+                        this.isEditIndex == -1 && this.formDialogType == 0 ? (
+                          <el-button
+                            type="text"
+                            onClick={() => {
+                              this.isEditIndex = index
+                            }}
+                          >
+                            编辑
+                          </el-button>
+                        ) : null,
+                        this.formDialogType == 0 ? (
+                          <el-button
+                            type="text"
+                            onClick={() => {
+                              this.delGoodsInfo(row, index)
+                            }}
+                          >
+                            删除
+                          </el-button>
+                        ) : null
+                      ]}
+                    </div>
+                  )
+                }
+              }
+            ]
+          }
+          return []
+        })()
+      ]
+    }
+  },
+  methods: {
+    // 获取商品详情
+    getGoodsDetl(row, cb, key = 'id') {
+      if (!row?.details?.id) {
+        goodsMaterialDetail({ id: row[key] }).then(res => {
+          Object.assign(row.details, res.data || {})
+          cb(row.details)
+        })
+      } else {
+        cb(row.details)
+      }
+    },
+    getBaseList() {
+      getBrandList({
+        status: true
+      }).then(res => {
+        this.brandList = res.data
+      })
+      getClassifyList({
+        type: 2,
+        status: true
+      }).then(res => {
+        this.ClassifyList = res.data
+      })
+      goodsMaterialList({
+        pageNum: 1,
+        pageSize: -1,
+        params: []
+      }).then(res => {
+        this.goodsMaterialList = res.data.records
+          .filter(item => item.isVirtyual !== 'YES' && item.state == 'ON')
+          .map(item => ({ ...item, details: {} }))
+      })
+    },
+    shanchujichu(row, num) {
+      if (num <= 0) {
+      }
+      if (num <= 1) {
+        row.smallId = ''
+        row.smallName = ''
+      }
+      if (num <= 2) {
+        row.goodsMaterialId = ''
+        row.goodsMaterialName = ''
+        row.specsName = ''
+        row.unit = ''
+        row.insideQty = ''
+        row.outQty = ''
+        row.partsQty = ''
+      }
+    },
+    getVfyKey(index, bool = true) {
+      return [
+        ...(() => {
+          if (bool) {
+            return [`items`]
+          }
+          return []
+        })(),
+        ...(() => {
+          if (index > -1) {
+            return [
+              // `items.${index}.brandId`,
+              // `items.${index}.mainId`,
+              // `items.${index}.smallId`,
+              // `items.${index}.goodsMaterialId`,
+              // `items.${index}.qty`,
+              // `items.${index}.price`,
+              `items.${index}.adjustQty`
+            ]
+          }
+          return []
+        })()
+      ]
+    },
+    eidtItems() {
+      try {
+        this.formData.items.map((item, index) => {
+          this.formData.items.map((item2, index2) => {
+            if (
+              index !== index2 &&
+              `${item.brandId}_${item.mainId}_${item.smallId}_${item.goodsMaterialId}` ==
+                `${item2.brandId}_${item2.mainId}_${item2.smallId}_${item2.goodsMaterialId}`
+            ) {
+              throw new Error('')
+            }
+          })
+        })
+      } catch (error) {
+        this.$message.warning('重复')
+        return false
+      }
+      return true
+    },
+    // 添加商品信息
+    addGoodsInfo() {
+      if (this.isEditIndex > -1) {
+        this.$refs.formRef.validateField(this.getVfyKey(this.isEditIndex), (valid, invalidFields, errLabels) => {
+          if (valid && this.eidtItems()) {
+            this.formData.items.unshift({
+              adjustQty: '',
+              amount: '',
+              brandId: '',
+              brandName: '',
+              factoryNo: '',
+              goodsMaterialId: '',
+              goodsMaterialName: '',
+              goodsPlanItemId: '',
+              inStockQty: '',
+              insideQty: '',
+              mainId: '',
+              mainName: '',
+              outQty: '',
+              partsQty: '',
+              price: '',
+              qty: '',
+              seriesName: '',
+              smallId: '',
+              smallName: '',
+              specsName: '',
+              surplusQty: '',
+              unit: '',
+              details: {}
+            })
+            this.isEditIndex = 0
+          }
+        })
+      } else if (this.eidtItems()) {
+        this.formData.items.unshift({
+          adjustQty: '',
+          amount: '',
+          brandId: '',
+          brandName: '',
+          factoryNo: '',
+          goodsMaterialId: '',
+          goodsMaterialName: '',
+          goodsPlanItemId: '',
+          inStockQty: '',
+          insideQty: '',
+          mainId: '',
+          mainName: '',
+          outQty: '',
+          partsQty: '',
+          price: '',
+          qty: '',
+          seriesName: '',
+          smallId: '',
+          smallName: '',
+          specsName: '',
+          surplusQty: '',
+          unit: '',
+          details: {}
+        })
+        this.isEditIndex = 0
+      }
+    },
+    delGoodsInfo(row, index) {
+      if (index > this.isEditIndex) {
+        this.formData?.items?.splice(index, 1)
+      } else if (index == this.isEditIndex) {
+        this.formData?.items?.splice(index, 1)
+        this.isEditIndex = -1
+      }
+    }
+  }
+}

+ 0 - 0
src/views/mallManagement/purchaseScheduleManagement/mixins/storage_table.js → src/views/mallManagement/purchaseScheduleManagement/purchasePlanAdjustment/mixins/storage_table.js


+ 21 - 21
src/views/mallManagement/purchaseScheduleManagement/purchaseSchedule/index.vue

@@ -49,18 +49,18 @@ import TemplatePage from '@/components/template/template-page-1.vue'
 import import_mixin from '@/components/template/import_mixin.js'
 import operation_mixin from '@/components/template/operation_mixin.js'
 import {
-  goodsPlanItemList,
-  goodsPlanListExport,
-  goodsPlanAdd,
-  goodsPlanUpdate,
-  goodsPlanSubmit,
-  goodsPlanDetail,
-  goodsPlanConfirm,
-  goodsPlanDel
-} from '@/api/purchaseSchedule.js'
-import form_ty from '../mixins/common_form'
-import storage_table from '../mixins/storage_table'
-import storage_goods from '../mixins/storage_goods'
+  goodsAdjustPlanList,
+  goodsAdjustPlanListExport,
+  goodsAdjustPlanAdd,
+  goodsAdjustPlanUpdate,
+  goodsAdjustPlanSubmit,
+  goodsAdjustPlanDetail,
+  goodsAdjustPlanConfirm,
+  goodsAdjustPlanDel
+} from '@/api/purchasePlanAdjustment.js'
+import form_ty from './mixins/common_form'
+import storage_table from './mixins/storage_table'
+import storage_goods from './mixins/storage_goods'
 import { delayPerform, firstPerform, intervalPerform, passivePerform, queuePerform } from 'js-perform-lock'
 export default {
   components: { TemplatePage },
@@ -166,10 +166,10 @@ export default {
     }),
     // 列表请求函数
     getList(p, cb) {
-      return goodsPlanItemList(p)
+      return goodsAdjustPlanList(p)
     },
     // 列表导出函数
-    exportList: goodsPlanListExport,
+    exportList: goodsAdjustPlanListExport,
     // 表格列解析渲染数据更改
     columnParsing(item, defaultData) {
       return defaultData
@@ -186,7 +186,7 @@ export default {
     },
     // 打开详情弹窗
     openDetailForm(row, type) {
-      goodsPlanDetail({ id: row.id }).then(res => {
+      goodsAdjustPlanDetail({ id: row.id }).then(res => {
         Object.assign(this.formData, res.data, {
           fileUrl: res.data.fileUrl ? [{ url: res.data.fileUrl }] : [],
           items: res.data.items.map(item => ({ ...item, details: {} }))
@@ -220,7 +220,7 @@ export default {
             return row.status == 'SAVE'
           },
           click: ({ row, index, column }) => {
-            goodsPlanDel({
+            goodsAdjustPlanDel({
               id: row.id
             }).then(res => {
               this.$message({
@@ -250,7 +250,7 @@ export default {
     save() {
       this.$refs.formRef.validateField(this.getVfyKey(this.isEditIndex), (valid, invalidFields, errLabels) => {
         if (valid && this.eidtItems()) {
-          goodsPlanAdd({
+          goodsAdjustPlanAdd({
             ...this.formData,
             items: this.formData.items.map((item, index) => ({ ...item, index: index + 1 })),
             fileUrl: this.formData.fileUrl.map(item => item.url).join(',')
@@ -268,7 +268,7 @@ export default {
     save2() {
       this.$refs.formRef.validateField(this.getVfyKey(this.isEditIndex), (valid, invalidFields, errLabels) => {
         if (valid && this.eidtItems()) {
-          goodsPlanUpdate({
+          goodsAdjustPlanUpdate({
             ...this.formData,
             items: this.formData.items.map((item, index) => ({ ...item, index: index + 1 })),
             fileUrl: this.formData.fileUrl.map(item => item.url).join(',')
@@ -287,12 +287,12 @@ export default {
     submit() {
       this.$refs.formRef.validateField(this.getVfyKey(this.isEditIndex), (valid, invalidFields, errLabels) => {
         if (valid && this.eidtItems()) {
-          goodsPlanUpdate({
+          goodsAdjustPlanUpdate({
             ...this.formData,
             items: this.formData.items.map((item, index) => ({ ...item, index: index + 1 })),
             fileUrl: this.formData.fileUrl.map(item => item.url).join(',')
           }).then(res => {
-            goodsPlanSubmit({
+            goodsAdjustPlanSubmit({
               id: this.formData.id
             }).then(res => {
               this.$message({
@@ -308,7 +308,7 @@ export default {
     },
     // 审核
     examine(type) {
-      goodsPlanConfirm({
+      goodsAdjustPlanConfirm({
         id: this.formData.id,
         statusEnum: type
       }).then(res => {

+ 0 - 2
src/views/mallManagement/purchaseScheduleManagement/mixins/common_form.js → src/views/mallManagement/purchaseScheduleManagement/purchaseSchedule/mixins/common_form.js

@@ -1,7 +1,5 @@
 import { required, diyRequired } from '@/components/template/rules_verify.js'
 import { listPageV2 } from '@/api/auxiliaryFittings/supplier'
-import { goodsPurchaseList, goodsPurchaseDetail } from '@/api/goodsPurchasedStored.js'
-import { storageListPageV2 } from '@/api/storage.js'
 import ImageUpload from '@/components/file-upload'
 export default {
   data() {

+ 0 - 0
src/views/mallManagement/purchaseScheduleManagement/mixins/storage_goods.js → src/views/mallManagement/purchaseScheduleManagement/purchaseSchedule/mixins/storage_goods.js


+ 48 - 0
src/views/mallManagement/purchaseScheduleManagement/purchaseSchedule/mixins/storage_table.js

@@ -0,0 +1,48 @@
+import { goodsPurchaseDetail } from '@/api/goodsPurchasedStored.js'
+import { commonTemplateDownload } from '@/api/common.js'
+export default {
+  data() {
+    return {}
+  },
+  computed: {
+    formItems2() {
+      return [
+        {
+          md: 24,
+          isShow: true,
+          name: 'slot-component',
+          formItemAttributes: {
+            label: '',
+            prop: '',
+            'label-width': '0px'
+          },
+          render: (h, { props, onInput }) => {
+            var { value } = props
+            return (
+              <div>
+                {[
+                  !!~[0, 1].indexOf(this.formDialogType) ? (
+                    <div style="margin-bottom:10px">
+                      <el-button type="primary" onClick={this.addGoodsInfo}>
+                        添加
+                      </el-button>
+                    </div>
+                  ) : null,
+                  <zj-table
+                    columns={this.storage_goods}
+                    tableData={this.formData.items}
+                    tableAttributes={{
+                      size: 'mini',
+                      border: true
+                    }}
+                  />
+                ]}
+              </div>
+            )
+          }
+        }
+      ]
+    }
+  },
+  methods: {}
+}