printModal.vue 8.6 KB

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