printModal.vue 8.5 KB

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