Commit cab9fdee by chenwq

膜卷号弹窗

1 parent 5b4aaab4
<template>
<GLDialog v-if="dialogShow" bigTitle="选择膜卷号" mode="big" :visible.sync="dialogShow" :close-on-click-modal="false">
<div class="detail-info">
<div>
已添加数量:
<span>{{ filmRollList.length }}</span>
</div>
<div>
最大可添加数量:
<span>{{ detailInfo.goodsNumber }}</span>
</div>
<div class="add-btn" @click="addLineTable">
添加一行
</div>
</div>
<GLTable :tableData="filmRollList" :noDataImg="url" :tableParams="tableParams" :hasPage="false">
<template slot="filmNum" slot-scope="scope">
<el-form :ref="'addForm' + scope.index" :model="scope.scope" size="small" :rules="rules">
<el-form-item style="margin-bottom: 0px" prop="filmNum">
<el-input v-model="scope.scope.filmNum" placeholder="请输入" maxlength="50" @input="e => handleInputFilmNum(e, scope.index)"></el-input>
</el-form-item>
</el-form>
</template>
<div class="table-btns" slot="auth-button" slot-scope="scope">
<el-button type="text" @click="handleDelete(scope.index)">删除</el-button>
</div>
</GLTable>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="dialogShow = false">关闭</el-button>
<el-button type="primary" size="small" @click="handleSave">保存入库</el-button>
</span>
</GLDialog>
</template>
<script>
import BigNumber from 'bignumber.js'
import * as dayjs from 'dayjs'
export default {
name: 'FilmDialog',
props: {
visible: {
type: Boolean,
default: false
},
id: {
type: String,
default: ''
},
info: {
type: Object,
default: () => { }
}
},
watch: {
visible(val) {
if (val) {
this.detailInfo = this.$common.utils.deepClone(this.info || {})
if (!this.info.filmRollList) {
this.filmRollList = [{ filmNum: '' }]
return true
}
this.info?.filmRollList.forEach(item => {
this.filmRollList.push({
filmNum: item
})
})
}
}
},
computed: {
dialogShow: {
get() {
return this.visible
},
set(val) {
this.$emit('update:visible', val)
}
}
},
data() {
// var checkPrice = (rule, value, callback) => {
// if (isNaN(+value)) {
// callback(new Error('请输入数字值'))
// } else {
// if (value <= 0 || value > 999999) {
// callback(new Error('仅支持输入0~999999'))
// } else {
// callback()
// }
// }
// }
return {
dayjs: dayjs,
filmRollList: [],
tableParams: {
tableOption: true,
tableColumns: [
{
label: '膜卷号',
prop: 'filmNum',
addHtml: 'filmNum'
}
]
},
rules: {
filmNum: [
{ required: true, message: '请输入膜卷号', trigger: 'blur' }
// { validator: checkPrice, trigger: 'blur' }
]
},
detailInfo: {},
tableData: []
}
},
created() { },
methods: {
// lookNumber(data) {
// this.innerVisible = true
// this.tableData = data.map(item => {
// return { cardNum: item }
// })
// },
handleInputFilmNum(val, idx) {
const reg = /^[0-9a-zA-Z]*$/
if (!reg.test(val)) {
this.filmRollList[idx].filmNum = val.slice(0, val.length - 1)
}
},
handleDetailClose() {
this.dialogShow = false
},
handleDelete(idx) {
if (this.filmRollList.length > 1) {
this.filmRollList.splice(idx, 1)
}
},
addLineTable() {
if (this.filmRollList.length == this.detailInfo.goodsNumber) {
return true
}
this.filmRollList.push({
filmNum: ''
})
},
validateForm(form) {
return new Promise(resolve => {
form.validate(valid => {
if (valid) {
resolve()
}
})
})
},
handleSave() {
let flag = true
for (let i = 0; i < this.filmRollList.length; i++) {
this.$refs['addForm' + i].validate(valid => {
flag = valid
})
if (!flag) {
return true
}
}
let list = this.filmRollList.map(item => item.filmNum)
this.$emit('handleConfirm', list)
}
}
}
</script>
<style lang="scss" scoped>
.detail-info {
display: flex;
align-items: center;
justify-content: space-between;
color: #666666ff;
font-size: 14px;
margin-bottom: 16px;
span {
color: #333333ff;
}
.add-btn {
font-size: 14px;
color: #5850ff;
cursor: pointer;
border: 1px solid #5850ff;
border-radius: 4px;
padding: 6px 16px;
}
}
.table-wrap {
box-sizing: border-box;
margin-top: 16px;
/deep/ .el-form-item__error {
padding-top: 2px;
z-index: 9999999;
position: static;
}
/deep/ td.el-table__cell {
height: 64px;
}
}
// .lookNumber {
// font-size: 14px;
// color: #5850ff !important;
// cursor: pointer;
// margin-left: 8px;
// }
.look-card-wrap {
/deep/.el-table th.el-table__cell > .cell {
padding: 0 16px;
text-align: center;
}
/deep/.el-table__body td.el-table__cell {
text-align: center;
}
}
</style>
......@@ -19,6 +19,16 @@
<el-input v-model="scope.scope.goodsNumber" placeholder="请输入" @blur="handleCalculate(scope.scope, 'goodsNumber')"></el-input>
</el-form-item>
</template>
<template slot="film" slot-scope="scope">
<div v-if="scope.scope.goodsName == '太阳膜'">
<el-button v-if="!scope.scope.filmRollList" type="text" @click="handleSelectFilm(scope.scope, scope.index)">请选择</el-button>
<div v-else>
{{ scope.scope.filmRollList.length }}
<el-button type="text" @click="handleSelectFilm(scope.scope, scope.index)">重新选择</el-button>
</div>
</div>
<div v-else>--</div>
</template>
<template slot="upgradePurchasePrice" slot-scope="scope">
<el-form-item style="margin-bottom: 0px" :prop="'tableData.' + scope.index + '.upgradePurchasePrice'" :rules="rules.upgradePurchasePrice">
<el-input v-model="scope.scope.upgradePurchasePrice" placeholder="请输入" @blur="handleCalculate(scope.scope, 'upgradePurchasePrice')"></el-input>
......@@ -56,10 +66,12 @@
<el-button @click="handleSave(1)" type="primary" plain size="medium">保存</el-button>
<el-button type="primary" @click="handleSave(2)" size="medium">保存并入库</el-button>
</GLFooter>
<filmDialog :visible.sync="filmVisible" :info="info" @handleConfirm="handleFilmConfirm"></filmDialog>
</div>
</template>
<script>
import BigNumber from 'bignumber.js'
import filmDialog from './components/FilmDialog'
export default {
data() {
var checkPrice = (rule, value, callback) => {
......@@ -94,7 +106,7 @@ export default {
putMerchantId: [{ required: true, message: '请选择入库门店', trigger: 'change' }]
},
formdata: {
tableData: [{ upgradeGoodsId: '', type: '', goodsName: '', goodsNumber: '', upgradePurchasePrice: '', goodsTotalPrice: '', putYqMerchantId: '', putYqMerchantName: '', putMerchantId: '', putMerchantName: '' , refByYqShopList: []}]
tableData: [{ upgradeGoodsId: '', type: '', goodsName: '', goodsNumber: '', upgradePurchasePrice: '', goodsTotalPrice: '', putYqMerchantId: '', putYqMerchantName: '', putMerchantId: '', putMerchantName: '', refByYqShopList: [] }]
},
tableParams: {
tableOption: true,
......@@ -118,12 +130,17 @@ export default {
addHtml: 'goodsNumber'
},
{
label: '采购单价',
label: '膜卷号',
prop: 'filmRollList',
addHtml: 'film'
},
{
label: '采购单价/元',
prop: 'upgradePurchasePrice',
addHtml: 'upgradePurchasePrice'
},
{
label: '采购总额/元',
label: '采购总价/元',
prop: 'goodsTotalPrice',
addHtml: 'goodsTotalPrice'
},
......@@ -141,9 +158,14 @@ export default {
},
goodsList: [],
storeUsageList: [],
refByYqShopList: []
refByYqShopList: [],
filmVisible: false,
info: {}
}
},
components: {
filmDialog
},
created() {
this.getfwsGoodsList()
this.getMerchantList()
......@@ -272,15 +294,31 @@ export default {
}
})
},
filmIsVisible() {
this.filmVisible = !this.filmVisible
},
handleSelectFilm(row, idx) {
if (!row.goodsNumber) {
this.$message.error('请先完善采购数量')
return
}
this.filmIsVisible()
this.filmIdx = idx
this.info = row
},
handleFilmConfirm(list) {
this.formdata.tableData[this.filmIdx].filmRollList = list
this.filmIsVisible()
},
handleCalculate(data, key) {
if (key == 'goodsNumber') {
data[key] = data[key] ? new BigNumber(data[key]).dp(0).toNumber() : ''
data.goodsTotalPrice =
data.upgradePurchasePrice && data.goodsNumber
? new BigNumber(data.upgradePurchasePrice)
.times(data.goodsNumber)
.dp(2)
.toNumber()
.times(data.goodsNumber)
.dp(2)
.toNumber()
: ''
return
}
......@@ -291,17 +329,17 @@ export default {
upgradePurchasePrice: data => {
data.goodsTotalPrice = data.upgradePurchasePrice
? new BigNumber(data.upgradePurchasePrice)
.times(data.goodsNumber)
.dp(2)
.toNumber()
.times(data.goodsNumber)
.dp(2)
.toNumber()
: ''
},
goodsTotalPrice: data => {
data.upgradePurchasePrice = data.goodsTotalPrice
? new BigNumber(data.goodsTotalPrice)
.div(data.goodsNumber)
.dp(2)
.toNumber()
.div(data.goodsNumber)
.dp(2)
.toNumber()
: ''
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!