printModal.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <a-modal
  3. centered
  4. :footer="null"
  5. :maskClosable="false"
  6. class="sales-print-type-modal"
  7. :title="modalTit"
  8. v-model="isShow"
  9. @cancel="isShow=false"
  10. :width="600">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <a-form-model
  13. id="sales-print-form"
  14. ref="ruleForm"
  15. :model="form"
  16. :rules="rules"
  17. :label-col="formItemLayout.labelCol"
  18. :wrapper-col="formItemLayout.wrapperCol"
  19. >
  20. <a-form-model-item label="销售单号">{{ itemData&&itemData.salesBillNo || '--' }}</a-form-model-item>
  21. <a-form-model-item label="客户名称">{{ itemData&&itemData.buyerName || '--' }}</a-form-model-item>
  22. <a-form-model-item label="产品分类" prop="id" v-if="nowType=='SALES_BILL_TYPE'">
  23. <a-select id="sales-print-form" v-model="form.id" placeholder="请选择产品分类">
  24. <a-select-option v-for="item in typeList" :value="item.id" :key="item.id">
  25. <span v-if="item.id != 'all'">{{ item.productBrandName }} - {{ item.productTypeName3 }}</span>
  26. <span v-else>全部</span>
  27. </a-select-option>
  28. </a-select>
  29. </a-form-model-item>
  30. <a-form-model-item label="是否缺货产品" prop="dataScope" v-if="nowType=='export'">
  31. <a-radio-group v-model="form.dataScope">
  32. <a-radio value="all">全部</a-radio>
  33. <a-radio value="ENOUGH">有库存</a-radio>
  34. <a-radio value="LESS">缺货</a-radio>
  35. </a-radio-group>
  36. </a-form-model-item>
  37. <a-form-model-item label="产品售价" prop="priceType">
  38. <!-- 销售分类打印 -->
  39. <a-radio-group v-model="form.priceType" v-if="nowType=='SALES_BILL_TYPE'">
  40. <a-radio value="SALES_BILL_TYPE_COST">打印</a-radio>
  41. <a-radio value="SALES_BILL_TYPE">不打印</a-radio>
  42. </a-radio-group>
  43. <!-- 销售打印 -->
  44. <a-radio-group v-model="form.priceType" v-if="nowType=='SALES_BILL'">
  45. <a-radio value="SALES_BILL_COST">打印</a-radio>
  46. <a-radio value="SALES_BILL">不打印</a-radio>
  47. </a-radio-group>
  48. <!-- 销售导出 -->
  49. <a-radio-group v-model="form.priceType" v-if="nowType=='export'">
  50. <a-radio :value="form.dataScope == 'ENOUGH' ? 'SALES_BILL_COST_NOT_LACK':'SALES_BILL_COST'">导出</a-radio>
  51. <a-radio :value="form.dataScope == 'ENOUGH' ? 'SALES_BILL_NOT_LACK':'SALES_BILL'">不导出</a-radio>
  52. </a-radio-group>
  53. </a-form-model-item>
  54. <a-form-model-item label="货位编号" prop="orderBy" v-if="nowType=='SALES_BILL_TYPE'">
  55. <a-radio-group v-model="form.orderBy">
  56. <a-radio value="sbd.STACK_PLACE_CODE ASC">打印(↑升序)</a-radio>
  57. <a-radio value="sbd.STACK_PLACE_CODE DESC">打印(↓降序)</a-radio>
  58. <a-radio value="-1">不打印</a-radio>
  59. </a-radio-group>
  60. </a-form-model-item>
  61. </a-form-model>
  62. <div class="btn-cont">
  63. <a-button :type="nowType=='export'?'primary':''" id="sales-print-save" @click="handleSave()">{{ nowType=='export' ? '导出' : '打印预览' }}</a-button>
  64. <a-button :type="nowType=='export'?'':'primary'" id="sales-print-back" @click="handleCancel" style="margin-left: 15px;">{{ nowType=='export' ? '取消' : '快捷打印' }}</a-button>
  65. </div>
  66. </a-spin>
  67. </a-modal>
  68. </template>
  69. <script>
  70. import { salesDetailProductType } from '@/api/sales'
  71. export default {
  72. props: {
  73. openModal: { // 弹框显示状态
  74. type: Boolean,
  75. default: false
  76. },
  77. itemData: {
  78. type: Object,
  79. default: () => {
  80. return null
  81. }
  82. },
  83. nowType: {
  84. type: String,
  85. default: ''
  86. }
  87. },
  88. data () {
  89. return {
  90. isShow: this.openModal, // 是否打开弹框
  91. form: {
  92. id: 'all',
  93. dataScope: 'all',
  94. priceType: undefined,
  95. orderBy: undefined
  96. },
  97. rules: {
  98. id: [{ required: true, message: '请选择产品分类', trigger: 'change' }],
  99. dataScope: [{ required: true, message: '请选择是否缺货产品', trigger: 'change' }],
  100. priceType: [{ required: true, message: '请选择产品售价', trigger: 'change' }],
  101. orderBy: [{ required: true, message: '请选择货位编号', trigger: 'change' }]
  102. },
  103. formItemLayout: {
  104. labelCol: { span: 6 },
  105. wrapperCol: { span: 15 }
  106. },
  107. spinning: false,
  108. typeList: []
  109. }
  110. },
  111. computed: {
  112. modalTit () {
  113. let title = ''
  114. if (this.nowType == 'SALES_BILL') {
  115. title = '销售打印'
  116. } else if (this.nowType == 'SALES_BILL_TYPE') {
  117. title = '销售分类打印'
  118. } else if (this.nowType == 'export') {
  119. title = '导出Excel'
  120. }
  121. return title
  122. }
  123. },
  124. methods: {
  125. // 确认
  126. handleSave (isPrint) {
  127. const _this = this
  128. this.$refs.ruleForm.validate(valid => {
  129. if (valid) {
  130. // 分类打印
  131. if (_this.nowType == 'SALES_BILL_TYPE') {
  132. const item = _this.typeList.find(item => item.id == _this.form.id)
  133. if (item) {
  134. const obj = {
  135. salesBillSn: _this.itemData.salesBillSn,
  136. productBrandSn: item.productBrandSn,
  137. productTypeSn3: item.productTypeSn3,
  138. priceType: _this.form.priceType,
  139. type: isPrint || 'preview'
  140. }
  141. // 打印货位编号
  142. if (_this.form.orderBy != '-1') {
  143. obj.orderBy = _this.form.orderBy
  144. obj.priceType = obj.priceType + '_STACK_PLACE'
  145. }
  146. _this.$emit('ok', obj)
  147. }
  148. } else if (_this.nowType == 'SALES_BILL') {
  149. const obj = {
  150. salesBillSn: _this.itemData.salesBillSn,
  151. priceType: _this.form.priceType,
  152. type: isPrint || 'preview'
  153. }
  154. _this.$emit('ok', obj)
  155. } else if (_this.nowType == 'export') {
  156. const obj = {
  157. salesBillSn: _this.itemData.salesBillSn,
  158. priceType: _this.form.priceType,
  159. dataScope: _this.form.dataScope == 'all' ? '' : _this.form.dataScope,
  160. type: isPrint || 'preview'
  161. }
  162. obj.showPriceFlag = _this.itemData.showPriceFlag
  163. _this.$emit('ok', obj)
  164. }
  165. _this.isShow = false
  166. } else {
  167. console.log('error submit!!')
  168. return false
  169. }
  170. })
  171. },
  172. // 取消选择分类
  173. handleCancel () {
  174. if (this.nowType == 'export') {
  175. this.isShow = false
  176. } else {
  177. this.handleSave('print')
  178. }
  179. },
  180. // 获取该销售单产品二级分类
  181. getTypeData () {
  182. this.typeList = [{ id: 'all' }]
  183. salesDetailProductType({ sn: this.itemData.salesBillSn || null }).then(res => {
  184. if (res.status == 200) {
  185. if (res.data && res.data.length > 0) {
  186. this.typeList = [...this.typeList, ...res.data]
  187. }
  188. }
  189. })
  190. }
  191. },
  192. watch: {
  193. // 父页面传过来的弹框状态
  194. openModal (newValue, oldValue) {
  195. this.isShow = newValue
  196. },
  197. // 重定义的弹框状态
  198. isShow (newValue, oldValue) {
  199. if (!newValue) {
  200. this.$emit('close')
  201. this.$refs.ruleForm.resetFields()
  202. } else {
  203. if (this.nowType == 'SALES_BILL_TYPE') {
  204. this.getTypeData()
  205. }
  206. }
  207. }
  208. }
  209. }
  210. </script>
  211. <style lang="less">
  212. .sales-print-type-modal{
  213. .btn-cont {
  214. text-align: center;
  215. margin: 35px 0 10px;
  216. }
  217. }
  218. </style>