123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- <template>
- <a-modal
- centered
- :footer="null"
- :maskClosable="false"
- class="sales-print-type-modal"
- :title="modalTit"
- v-model="isShow"
- @cancel="isShow=false"
- :width="600">
- <a-spin :spinning="spinning" tip="Loading...">
- <a-form-model
- id="sales-print-form"
- ref="ruleForm"
- :model="form"
- :rules="rules"
- :label-col="formItemLayout.labelCol"
- :wrapper-col="formItemLayout.wrapperCol"
- >
- <a-form-model-item label="销售单号">{{ itemData&&itemData.salesBillNo || '--' }}</a-form-model-item>
- <a-form-model-item label="客户名称">{{ itemData&&itemData.buyerName || '--' }}</a-form-model-item>
- <a-form-model-item label="产品分类" prop="id" v-if="nowType=='SALES_BILL_TYPE'">
- <a-select id="sales-print-form" v-model="form.id" placeholder="请选择产品分类">
- <a-select-option v-for="item in typeList" :value="item.id" :key="item.id">
- <span v-if="item.id != 'all'">{{ item.productBrandName }} - {{ item.productTypeName3 }}</span>
- <span v-else>全部</span>
- </a-select-option>
- </a-select>
- </a-form-model-item>
- <a-form-model-item label="是否缺货产品" prop="dataScope" v-if="nowType=='export'">
- <a-radio-group v-model="form.dataScope">
- <a-radio value="all">全部</a-radio>
- <a-radio value="ENOUGH">有库存</a-radio>
- <a-radio value="LESS">缺货</a-radio>
- </a-radio-group>
- </a-form-model-item>
- <a-form-model-item label="产品售价" prop="priceType">
- <!-- 销售分类打印 -->
- <a-radio-group v-model="form.priceType" v-if="nowType=='SALES_BILL_TYPE'">
- <a-radio value="SALES_BILL_TYPE_COST">打印</a-radio>
- <a-radio value="SALES_BILL_TYPE">不打印</a-radio>
- </a-radio-group>
- <!-- 销售打印 -->
- <a-radio-group v-model="form.priceType" v-if="nowType=='SALES_BILL'">
- <a-radio value="SALES_BILL_COST">打印</a-radio>
- <a-radio value="SALES_BILL">不打印</a-radio>
- </a-radio-group>
- <!-- 销售导出 -->
- <a-radio-group v-model="form.priceType" v-if="nowType=='export'">
- <a-radio :value="form.dataScope == 'ENOUGH' ? 'SALES_BILL_COST_NOT_LACK':'SALES_BILL_COST'">导出</a-radio>
- <a-radio :value="form.dataScope == 'ENOUGH' ? 'SALES_BILL_NOT_LACK':'SALES_BILL'">不导出</a-radio>
- </a-radio-group>
- </a-form-model-item>
- <a-form-model-item label="货位编号" prop="orderBy" v-if="nowType=='SALES_BILL_TYPE'">
- <a-radio-group v-model="form.orderBy">
- <a-radio value="sbd.STACK_PLACE_CODE ASC">打印(↑升序)</a-radio>
- <a-radio value="sbd.STACK_PLACE_CODE DESC">打印(↓降序)</a-radio>
- <a-radio value="-1">不打印</a-radio>
- </a-radio-group>
- </a-form-model-item>
- </a-form-model>
- <div class="btn-cont">
- <a-button :type="nowType=='export'?'primary':''" id="sales-print-save" @click="handleSave()">{{ nowType=='export' ? '导出' : '打印预览' }}</a-button>
- <a-button :type="nowType=='export'?'':'primary'" id="sales-print-back" @click="handleCancel" style="margin-left: 15px;">{{ nowType=='export' ? '取消' : '快捷打印' }}</a-button>
- </div>
- </a-spin>
- </a-modal>
- </template>
- <script>
- import { salesDetailProductType } from '@/api/sales'
- export default {
- props: {
- openModal: { // 弹框显示状态
- type: Boolean,
- default: false
- },
- itemData: {
- type: Object,
- default: () => {
- return null
- }
- },
- nowType: {
- type: String,
- default: ''
- }
- },
- data () {
- return {
- isShow: this.openModal, // 是否打开弹框
- form: {
- id: 'all',
- dataScope: 'all',
- priceType: undefined,
- orderBy: undefined
- },
- rules: {
- id: [{ required: true, message: '请选择产品分类', trigger: 'change' }],
- dataScope: [{ required: true, message: '请选择是否缺货产品', trigger: 'change' }],
- priceType: [{ required: true, message: '请选择产品售价', trigger: 'change' }],
- orderBy: [{ required: true, message: '请选择货位编号', trigger: 'change' }]
- },
- formItemLayout: {
- labelCol: { span: 6 },
- wrapperCol: { span: 15 }
- },
- spinning: false,
- typeList: []
- }
- },
- computed: {
- modalTit () {
- let title = ''
- if (this.nowType == 'SALES_BILL') {
- title = '销售打印'
- } else if (this.nowType == 'SALES_BILL_TYPE') {
- title = '销售分类打印'
- } else if (this.nowType == 'export') {
- title = '导出Excel'
- }
- return title
- }
- },
- methods: {
- // 确认
- handleSave (isPrint) {
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- // 分类打印
- if (_this.nowType == 'SALES_BILL_TYPE') {
- const item = _this.typeList.find(item => item.id == _this.form.id)
- if (item) {
- const obj = {
- salesBillSn: _this.itemData.salesBillSn,
- productBrandSn: item.productBrandSn,
- productTypeSn3: item.productTypeSn3,
- priceType: _this.form.priceType,
- type: isPrint || 'preview'
- }
- // 打印货位编号
- if (_this.form.orderBy != '-1') {
- obj.orderBy = _this.form.orderBy
- obj.priceType = obj.priceType + '_STACK_PLACE'
- }
- _this.$emit('ok', obj)
- }
- } else if (_this.nowType == 'SALES_BILL') {
- const obj = {
- salesBillSn: _this.itemData.salesBillSn,
- priceType: _this.form.priceType,
- type: isPrint || 'preview'
- }
- _this.$emit('ok', obj)
- } else if (_this.nowType == 'export') {
- const obj = {
- salesBillSn: _this.itemData.salesBillSn,
- priceType: _this.form.priceType,
- dataScope: _this.form.dataScope == 'all' ? '' : _this.form.dataScope,
- type: isPrint || 'preview'
- }
- obj.showPriceFlag = _this.itemData.showPriceFlag
- _this.$emit('ok', obj)
- }
- _this.isShow = false
- } else {
- console.log('error submit!!')
- return false
- }
- })
- },
- // 取消选择分类
- handleCancel () {
- if (this.nowType == 'export') {
- this.isShow = false
- } else {
- this.handleSave('print')
- }
- },
- // 获取该销售单产品二级分类
- getTypeData () {
- this.typeList = [{ id: 'all' }]
- salesDetailProductType({ sn: this.itemData.salesBillSn || null }).then(res => {
- if (res.status == 200) {
- if (res.data && res.data.length > 0) {
- this.typeList = [...this.typeList, ...res.data]
- }
- }
- })
- }
- },
- watch: {
- // 父页面传过来的弹框状态
- openModal (newValue, oldValue) {
- this.isShow = newValue
- },
- // 重定义的弹框状态
- isShow (newValue, oldValue) {
- if (!newValue) {
- this.$emit('close')
- this.$refs.ruleForm.resetFields()
- } else {
- if (this.nowType == 'SALES_BILL_TYPE') {
- this.getTypeData()
- }
- }
- }
- }
- }
- </script>
- <style lang="less">
- .sales-print-type-modal{
- .btn-cont {
- text-align: center;
- margin: 35px 0 10px;
- }
- }
- </style>
|