|
@@ -0,0 +1,603 @@
|
|
|
+<template>
|
|
|
+ <el-form
|
|
|
+ class="pd"
|
|
|
+ ref="dataForm"
|
|
|
+ v-loading="loading"
|
|
|
+ :model="dataForm"
|
|
|
+ :rules="dataFormRules"
|
|
|
+ label-position="left"
|
|
|
+ label-width="90px"
|
|
|
+ >
|
|
|
+ <el-form-item v-if="formDisabled" label="单据编号" prop="sheetId">
|
|
|
+ <el-input disabled :value="dataForm.sheetId" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="网点" prop="shopId">
|
|
|
+ <el-select v-model="dataForm.shopId" :disabled="formDisabled" placeholder="请选择网点" style="width: 100%">
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in authShop"
|
|
|
+ :key="index"
|
|
|
+ :label="shopLabelStrHandle(item)"
|
|
|
+ :value="item.shopId"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="供应商" prop="venderId">
|
|
|
+ <el-select
|
|
|
+ v-model="dataForm.venderId"
|
|
|
+ filterable
|
|
|
+ :disabled="formDisabled"
|
|
|
+ placeholder="请选择供应商"
|
|
|
+ style="width: 100%"
|
|
|
+ @change="getVenderGoodsList"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in venderList"
|
|
|
+ :key="index"
|
|
|
+ :label="vendorLabelStrHandle(item)"
|
|
|
+ :value="item.venderId"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="采购日期" prop="purchaseTime">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="dataForm.purchaseTime"
|
|
|
+ type="date"
|
|
|
+ placeholder="选择采购日期"
|
|
|
+ value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
+ :disabled="inputParam.openType === 'view'"
|
|
|
+ style="width: 100%"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-form-item label="采购单图片" prop="image">
|
|
|
+ <template v-if="inputParam.openType !== 'view'">
|
|
|
+ <el-upload
|
|
|
+ v-loading="imageLoading"
|
|
|
+ element-loading-text="上传中"
|
|
|
+ element-loading-spinner="el-icon-loading"
|
|
|
+ element-loading-background="rgba(0, 0, 0, 0.8)"
|
|
|
+ :disabled="imageLoading"
|
|
|
+ class="avatar-uploader"
|
|
|
+ :action="baseURL + 'common/upload'"
|
|
|
+ :headers="myHeaders"
|
|
|
+ :show-file-list="false"
|
|
|
+ :on-success="uploadSuccess"
|
|
|
+ :before-upload="beforeUpload"
|
|
|
+ :on-error="uploadError"
|
|
|
+ >
|
|
|
+ <img v-if="dataForm.image" :src="$showImgUrl(dataForm.image)" class="avatar" alt="" />
|
|
|
+ <i v-else class="el-icon-plus avatar-uploader-icon" />
|
|
|
+ <div slot="tip" class="el-upload__tip" style="margin-top: 0; line-height: 20px">只支持上传jpg/png文件</div>
|
|
|
+ </el-upload>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <el-image
|
|
|
+ style="width: 100px; height: 100px"
|
|
|
+ :src="$showImgUrl(dataForm.image)"
|
|
|
+ :preview-src-list="[$showImgUrl(dataForm.image)]"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item v-if="dataForm.notes3" label="申请单备注">
|
|
|
+ <el-input v-model="dataForm.notes3" disabled />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item v-if="dataForm.notes2" label="供应商备注">
|
|
|
+ <el-input v-model="dataForm.notes2" disabled />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="备注" prop="notes">
|
|
|
+ <el-input
|
|
|
+ v-model="dataForm.notes"
|
|
|
+ autocomplete="off"
|
|
|
+ placeholder="备注"
|
|
|
+ :disabled="inputParam.openType === 'view'"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-row>
|
|
|
+ <el-col>
|
|
|
+ <el-divider>采购明细</el-divider>
|
|
|
+ </el-col>
|
|
|
+ <el-col>
|
|
|
+ <el-table
|
|
|
+ ref="goodsTable"
|
|
|
+ :data="dataForm.items"
|
|
|
+ max-height="500"
|
|
|
+ size="mini"
|
|
|
+ border
|
|
|
+ header-cell-class-name="headerRowColor"
|
|
|
+ show-summary
|
|
|
+ :summary-method="getSummaries"
|
|
|
+ class="detail-table"
|
|
|
+ >
|
|
|
+ <el-table-column prop="goodsId" label="辅材编号" />
|
|
|
+ <el-table-column prop="goodsName" label="辅材名称" min-width="180" />
|
|
|
+ <el-table-column prop="purchaseQty" label="订货数量" header-align="left" align="center" />
|
|
|
+ <el-table-column prop="deliverQty" label="供应数量" header-align="left" align="center" />
|
|
|
+ <el-table-column prop="estimateCost" label="预估进价" header-align="left" align="center" />
|
|
|
+ <el-table-column prop="cost" label="进价" header-align="left" align="center">
|
|
|
+ <template slot-scope="{ $index, row }">
|
|
|
+ <label v-if="inputParam.openType === 'view'">{{ row.cost }}</label>
|
|
|
+ <el-form-item
|
|
|
+ v-else
|
|
|
+ style="margin: 18px 0"
|
|
|
+ label-width="0"
|
|
|
+ size="mini"
|
|
|
+ :prop="'items.' + $index + '.cost'"
|
|
|
+ :rules="dataFormRules.cost"
|
|
|
+ >
|
|
|
+ <el-input v-model="row.cost" size="mini" @change="changeCostValue($index, row)" />
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="recQty" label="验收数量" header-align="left" align="center" width="100">
|
|
|
+ <template slot-scope="{ $index, row }">
|
|
|
+ <label v-if="inputParam.openType === 'view'">{{ row.recQty + ' /' + row.measureUnit }}</label>
|
|
|
+ <el-form-item
|
|
|
+ v-else
|
|
|
+ style="margin: 18px 0"
|
|
|
+ label-width="0"
|
|
|
+ size="mini"
|
|
|
+ :prop="'items.' + $index + '.recQty'"
|
|
|
+ :rules="dataFormRules.recQty"
|
|
|
+ >
|
|
|
+ <el-input v-model="row.recQty" size="mini" @change="changeCostValue($index, row)">
|
|
|
+ <template slot="suffix">{{ row.measureUnit }}</template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="recGiftQty" label="赠品数量" header-align="left" align="center">
|
|
|
+ <template slot-scope="{ $index, row }">
|
|
|
+ <label v-if="inputParam.openType === 'view'">{{ row.recGiftQty + ' /' + row.measureUnit }}</label>
|
|
|
+ <el-form-item
|
|
|
+ v-else
|
|
|
+ style="margin: 18px 0"
|
|
|
+ label-width="0"
|
|
|
+ size="mini"
|
|
|
+ :prop="'items.' + $index + '.recGiftQty'"
|
|
|
+ :rules="dataFormRules.recGiftQty"
|
|
|
+ >
|
|
|
+ <el-input v-model="row.recGiftQty" size="mini">
|
|
|
+ <template slot="suffix">{{ row.measureUnit }}</template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="costValue" label="验收金额" header-align="left" align="center" />
|
|
|
+ <el-table-column prop="inStockQty" label="入库数量" header-align="left" align="center" width="100">
|
|
|
+ <template slot-scope="{ $index, row }">
|
|
|
+ <label>{{ row.inStockQty + ' ' + row.salesUnit }}</label>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="inStockCost" label="入库进价" header-align="left" align="center" width="100">
|
|
|
+ <template slot-scope="{ $index, row }">
|
|
|
+ <label>{{ row.inStockCost + ' 元/' + row.salesUnit }}</label>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="measureUnit" label="采购单位" />
|
|
|
+ <el-table-column prop="unitQty" label="转换系数" header-align="left" align="center" width="95" />
|
|
|
+ <el-table-column prop="salesUnit" label="售卖单位" />
|
|
|
+ <el-table-column prop="productModel" label="商品型号" />
|
|
|
+ <el-table-column prop="specification" label="规格" />
|
|
|
+ </el-table>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24"
|
|
|
+ ><div>共 {{ goodsTotalCount }} 条记录</div></el-col
|
|
|
+ >
|
|
|
+ </el-row>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <div style="text-align: right">
|
|
|
+ <el-button @click="cancelForm">取 消</el-button>
|
|
|
+ <el-button v-if="checkBtn('edit')" type="primary" :disabled="saveBtn" @click="submitForm('edit')"
|
|
|
+ >保 存</el-button
|
|
|
+ >
|
|
|
+ <el-button v-if="checkBtn('confirm')" type="success" @click="confirmSheet(dataForm.sheetId)">审 核</el-button>
|
|
|
+ </div>
|
|
|
+ <el-dialog
|
|
|
+ width="70%"
|
|
|
+ title="商品列表"
|
|
|
+ :visible.sync="innerVisible"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ @close="$refs.goodsTable.clearSelection()"
|
|
|
+ >
|
|
|
+ <el-input
|
|
|
+ v-model="searchGoods"
|
|
|
+ size="small"
|
|
|
+ placeholder="输入 辅材名称 或 规格 模糊搜索"
|
|
|
+ style="margin-bottom: 5px"
|
|
|
+ :clearable="true"
|
|
|
+ />
|
|
|
+ <el-table
|
|
|
+ ref="goodsTable"
|
|
|
+ :data="
|
|
|
+ goodsList.filter(
|
|
|
+ data =>
|
|
|
+ !searchGoods ||
|
|
|
+ data.goodsName.toLowerCase().includes(searchGoods.toLowerCase()) ||
|
|
|
+ data.specification.toLowerCase().includes(searchGoods.toLowerCase())
|
|
|
+ )
|
|
|
+ "
|
|
|
+ :row-key="getRowKeys"
|
|
|
+ height="400"
|
|
|
+ size="mini"
|
|
|
+ border
|
|
|
+ header-cell-class-name="headerRowColor"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-table-column type="selection" width="55" :reserve-selection="true" />
|
|
|
+ <el-table-column prop="goodsId" label="辅材编号" />
|
|
|
+ <el-table-column prop="goodsCode" label="辅材代码" />
|
|
|
+ <el-table-column prop="goodsName" label="辅材名称" />
|
|
|
+ <el-table-column prop="categoryName" label="小类名称" />
|
|
|
+ <el-table-column prop="productModel" label="商品型号" />
|
|
|
+ <el-table-column prop="specification" label="规格" />
|
|
|
+ <el-table-column prop="qty" label="库存数量" />
|
|
|
+ </el-table>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="selGoods">确 定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </el-form>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { getVenderGoodsList, getVenderList } from '@/api/material-system/vender'
|
|
|
+import { computeVal } from '@/api/material-system/common'
|
|
|
+import { getToken } from '@/utils/auth'
|
|
|
+import {
|
|
|
+ addPurchaseSheet,
|
|
|
+ confirmPurchaseSheet,
|
|
|
+ editPurchaseSheet,
|
|
|
+ getPurchaseSheet
|
|
|
+} from '@/api/material-system/shop/purchase-sheet'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'PurchaseArea',
|
|
|
+ props: {
|
|
|
+ inputParam: {
|
|
|
+ type: Object,
|
|
|
+ default: function () {
|
|
|
+ return {
|
|
|
+ openType: 'add',
|
|
|
+ sheetId: ''
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ const validateCost = (rule, value, callback) => {
|
|
|
+ this.saveBtn = true
|
|
|
+ if (Number.isNaN(parseFloat(value))) {
|
|
|
+ return callback(new Error('请输入数字值'))
|
|
|
+ }
|
|
|
+ if (parseFloat(value) < 0) {
|
|
|
+ return callback(new Error('不能少于0'))
|
|
|
+ }
|
|
|
+ this.saveBtn = false
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ const validateRecQty = (rule, value, callback) => {
|
|
|
+ // const index = /^items\.([0-9]+)\.recQty/.exec(rule.fullField)[1]
|
|
|
+ // const deliverQty = this.dataForm.items[index].deliverQty
|
|
|
+ this.saveBtn = true
|
|
|
+ if (Number.isNaN(parseFloat(value))) {
|
|
|
+ return callback(new Error('请输入数字值'))
|
|
|
+ }
|
|
|
+ if (parseFloat(value) < 0) {
|
|
|
+ return callback(new Error('不能少于0'))
|
|
|
+ }
|
|
|
+ // if (index && deliverQty && parseFloat(value) > parseFloat(deliverQty)) {
|
|
|
+ // return callback(new Error('不能大于供应'))
|
|
|
+ // }
|
|
|
+ this.saveBtn = false
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ const validateRecGiftQty = (rule, value, callback) => {
|
|
|
+ this.saveBtn = true
|
|
|
+ if (Number.isNaN(parseFloat(value))) {
|
|
|
+ return callback(new Error('请输入数字值'))
|
|
|
+ }
|
|
|
+ if (parseFloat(value) < 0) {
|
|
|
+ return callback(new Error('不能少于0'))
|
|
|
+ }
|
|
|
+ this.saveBtn = false
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ imageLoading: false,
|
|
|
+ loading: true,
|
|
|
+ baseURL: process.env.VUE_APP_BASE_API,
|
|
|
+ myHeaders: { 'x-token': getToken() },
|
|
|
+ dataForm: {
|
|
|
+ sheetId: '', // 单据ID
|
|
|
+ shopId: '', // 网点ID
|
|
|
+ shopName: '', // 网点名称
|
|
|
+ venderId: '', // 供应商ID
|
|
|
+ venderName: '', // 供应商名称
|
|
|
+ purchaseTime: '', // 采购日期
|
|
|
+ image: '',
|
|
|
+ notes: '', // 备注
|
|
|
+ flag: '',
|
|
|
+ items: [] // 关系辅材列表
|
|
|
+ },
|
|
|
+ dataFormRules: {
|
|
|
+ purchaseTime: [{ require: true, message: '请选择采购日期', trigger: 'blur' }],
|
|
|
+ cost: [{ validator: validateCost, trigger: 'blur' }],
|
|
|
+ recQty: [{ validator: validateRecQty, trigger: 'blur' }],
|
|
|
+ recGiftQty: [{ validator: validateRecGiftQty, trigger: 'blur' }]
|
|
|
+ },
|
|
|
+ orgDataForm: {},
|
|
|
+ goodsList: [], // 商品列表
|
|
|
+ venderList: [], // 供应商列表
|
|
|
+ innerVisible: false,
|
|
|
+ searchGoods: '',
|
|
|
+ saveBtn: false // 保存按钮状态
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ formDisabled() {
|
|
|
+ return this.inputParam.openType === 'view' || this.dataForm.sheetId !== ''
|
|
|
+ },
|
|
|
+ goodsTotalCount: function () {
|
|
|
+ return this.dataForm && this.dataForm.items ? this.dataForm.items.length : 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ // 网点变动重新执行辅材获取资料
|
|
|
+ 'shopPurchaseForm.shopId': function () {
|
|
|
+ this.getVenderGoodsList(this.dataForm.venderId)
|
|
|
+ },
|
|
|
+ searchGoods: function () {
|
|
|
+ this.$refs.goodsTable.clearSelection()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.getVenderList()
|
|
|
+ this.getDetail()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getDetail(id) {
|
|
|
+ this.loading = true
|
|
|
+ const openType = this.inputParam.openType
|
|
|
+ const sheetId = id || this.inputParam.sheetId
|
|
|
+ if (openType !== 'add') {
|
|
|
+ getPurchaseSheet({ sheetId }).then(res => {
|
|
|
+ this.setDataForm(res.data)
|
|
|
+ if (openType !== 'view') {
|
|
|
+ this.getVenderGoodsList(this.dataForm.venderId)
|
|
|
+ }
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ cancelForm() {
|
|
|
+ this.$emit('getList')
|
|
|
+ this.$emit('update:isOpen', false)
|
|
|
+ },
|
|
|
+ submitForm(type) {
|
|
|
+ if (this.dataForm.items && this.dataForm.items.length === 0) {
|
|
|
+ this.$errorMsg('请添加商品后再保存!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.$refs.dataForm.validate(valid => {
|
|
|
+ if (!this.dataForm.image) {
|
|
|
+ this.$errorMsg('请添加附件图片')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (valid) {
|
|
|
+ if (type === 'edit') {
|
|
|
+ editPurchaseSheet(this.dataForm).then(() => {
|
|
|
+ this.getDetail(this.dataForm.sheetId)
|
|
|
+ this.$successMsg('保存成功')
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.dataForm.shopName = this.getArraysName(this.authShop, this.dataForm, 'shopId', 'shopName')
|
|
|
+ this.dataForm.venderName = this.getArraysName(this.venderList, this.dataForm, 'venderId', 'venderName')
|
|
|
+ addPurchaseSheet(this.dataForm).then(res => {
|
|
|
+ this.inputParam.openType = 'edit'
|
|
|
+ this.setDataForm(res.data)
|
|
|
+ this.$successMsg('保存成功')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ setDataForm(data) {
|
|
|
+ this.dataForm = {
|
|
|
+ sheetId: data.sheetId, // 单据编号
|
|
|
+ shopId: data.shopId, // 网点ID
|
|
|
+ venderId: data.venderId, // 供应商Id
|
|
|
+ purchaseTime: data.purchaseTime, // 采购日期
|
|
|
+ flag: data.flag,
|
|
|
+ image: data.image,
|
|
|
+ notes: data.notes, // 备注
|
|
|
+ items: data.items // 关系商品列表
|
|
|
+ }
|
|
|
+ Object.assign(this.orgDataForm, this.dataForm)
|
|
|
+ },
|
|
|
+ checkBtn(type) {
|
|
|
+ const typeMap = {
|
|
|
+ add: this.inputParam.openType === type,
|
|
|
+ edit: this.dataForm.flag === 2 && this.inputParam.openType === type,
|
|
|
+ confirm:
|
|
|
+ this.dataForm.flag === 2 &&
|
|
|
+ this.dataForm.sheetId !== '' &&
|
|
|
+ this.orgDataForm.purchaseTime &&
|
|
|
+ this.orgDataForm.image
|
|
|
+ }
|
|
|
+ // 检查按钮权限
|
|
|
+ return this.checkBtnRole(type) && typeMap[type]
|
|
|
+ },
|
|
|
+ // 获取供应商列表
|
|
|
+ getVenderList() {
|
|
|
+ getVenderList({ pageNum: 1, pageSize: -1, flag: 1 }).then(res => {
|
|
|
+ this.venderList = res.data.records
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 获取供应商关系辅材列表
|
|
|
+ getVenderGoodsList(val) {
|
|
|
+ if (val) {
|
|
|
+ getVenderGoodsList({
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: -1,
|
|
|
+ venderId: val,
|
|
|
+ flag: 1,
|
|
|
+ status: 1,
|
|
|
+ shopId: this.dataForm.shopId
|
|
|
+ }).then(res => {
|
|
|
+ this.goodsList = res.data.records
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getSummaries(param) {
|
|
|
+ const { columns, data } = param
|
|
|
+ const sums = []
|
|
|
+ columns.forEach((column, index) => {
|
|
|
+ if (index === 0) {
|
|
|
+ sums[index] = '合计'
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const values = data.map(item => Number(item[column.property]))
|
|
|
+ if (column.property === 'costValue') {
|
|
|
+ let count = 0
|
|
|
+ sums[index] = values.reduce((prev, curr) => {
|
|
|
+ const suffix = (curr + '').split('.')
|
|
|
+ if (suffix.length > 1) {
|
|
|
+ count = suffix[1].length > count ? suffix[1].length : count
|
|
|
+ }
|
|
|
+ const value = Number(curr)
|
|
|
+ if (!isNaN(value)) {
|
|
|
+ return prev + curr
|
|
|
+ } else {
|
|
|
+ return prev
|
|
|
+ }
|
|
|
+ }, 0)
|
|
|
+ sums[index] = parseFloat(sums[index]).toFixed(count)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return sums
|
|
|
+ },
|
|
|
+ // 进价或验收数量变动
|
|
|
+ changeCostValue(index, row) {
|
|
|
+ computeVal({
|
|
|
+ frontVal: row.recQty,
|
|
|
+ afterVal: row.cost,
|
|
|
+ operator: '*',
|
|
|
+ scale: 4
|
|
|
+ }).then(res => {
|
|
|
+ this.dataForm.items[index].costValue = res.data
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 选中辅材添加到表单中
|
|
|
+ selGoods() {
|
|
|
+ this.searchGoods = ''
|
|
|
+ this.$refs.goodsTable.selection.forEach(value => {
|
|
|
+ const index = this.dataForm.items.findIndex(item => {
|
|
|
+ return item.goodsId === value.goodsId
|
|
|
+ })
|
|
|
+ // 添加不在列表的商品
|
|
|
+ if (index < 0) {
|
|
|
+ this.dataForm.items.push({
|
|
|
+ goodsId: value.goodsId,
|
|
|
+ goodsName: value.goodsName,
|
|
|
+ cost: value.cost,
|
|
|
+ ndays: value.ndays,
|
|
|
+ purchaseQty: 0,
|
|
|
+ recQty: 0,
|
|
|
+ measureUnit: value.measureUnit,
|
|
|
+ unitQty: value.unitQty,
|
|
|
+ salesUnit: value.salesUnit,
|
|
|
+ recGiftQty: 0,
|
|
|
+ costValue: 0,
|
|
|
+ productModel: value.productModel,
|
|
|
+ specification: value.specification
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.$refs.goodsTable.clearSelection()
|
|
|
+ this.innerVisible = false
|
|
|
+ },
|
|
|
+ // 删除明细
|
|
|
+ delItem(index) {
|
|
|
+ this.dataForm.items.splice(index, 1)
|
|
|
+ },
|
|
|
+ getRowKeys(row) {
|
|
|
+ return row.goodsId
|
|
|
+ },
|
|
|
+ // 上传成功回调
|
|
|
+ uploadSuccess(res) {
|
|
|
+ this.imageLoading = false
|
|
|
+ this.dataForm.image = res.data.url
|
|
|
+ },
|
|
|
+ // 上传前检查
|
|
|
+ beforeUpload(file) {
|
|
|
+ if (this.imageLoading) {
|
|
|
+ this.$errorMsg('文件上传中,稍后再试!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ const fileSuffix = file.name.substring(file.name.lastIndexOf('.') + 1)
|
|
|
+ const whiteList = ['jpg', 'jpeg', 'png']
|
|
|
+ if (whiteList.indexOf(fileSuffix) === -1) {
|
|
|
+ this.$errorMsg('只支持上传jpg/png文件!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ this.imageLoading = true
|
|
|
+ },
|
|
|
+ uploadError() {
|
|
|
+ this.imageLoading = false
|
|
|
+ },
|
|
|
+ // 审核 采购入库单
|
|
|
+ confirmSheet(sheetId) {
|
|
|
+ this.$confirm(
|
|
|
+ `此操作将审核 ${sheetId} 单据,<span style="color: #ff0000;">当前内容如果已修改将忽略保存</span>,是否继续?`,
|
|
|
+ '提示',
|
|
|
+ {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ dangerouslyUseHTMLString: true
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then(() => {
|
|
|
+ this.loading = true
|
|
|
+ confirmPurchaseSheet({ sheetId: sheetId }).then(
|
|
|
+ () => {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.inputParam.openType = 'view'
|
|
|
+ this.getDetail(sheetId)
|
|
|
+ this.$successMsg('审核成功')
|
|
|
+ this.loading = false
|
|
|
+ }, 2000)
|
|
|
+ },
|
|
|
+ () => {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ )
|
|
|
+ })
|
|
|
+ .catch(() => console.log('取消'))
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.detail-table {
|
|
|
+ width: 100%;
|
|
|
+ margin: 15px 0;
|
|
|
+ ::v-deep .el-input__suffix-inner {
|
|
|
+ color: red;
|
|
|
+ }
|
|
|
+}
|
|
|
+.pd {
|
|
|
+ padding: 20px 20px 0 20px;
|
|
|
+}
|
|
|
+</style>
|