printModal.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <a-modal
  3. centered
  4. :footer="null"
  5. :maskClosable="false"
  6. class="allocateBill-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="allocateBill-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 style="margin-bottom: 0;" label="调拨单号">{{ itemData&&itemData.allocateNo || '--' }}</a-form-model-item>
  21. <a-form-model-item style="margin-bottom: 0;" label="调往对象">{{ itemData&&itemData.targetName || '--' }}</a-form-model-item>
  22. <a-form-model-item style="margin-bottom: 0;" label="发货编号">{{ itemData&&itemData.sendNo || '--' }}</a-form-model-item>
  23. <a-form-model-item style="margin-bottom: 0;" label="收货客户名称">{{ itemData&&itemData.receiverName || '--' }}</a-form-model-item>
  24. <a-form-model-item style="margin-bottom: 0;" label="产品分类" prop="id" v-if="nowType=='dbflPrint'||nowType=='dbflExport'">
  25. <a-select id="allocateBill-print-form" v-model="form.id" placeholder="请选择产品分类">
  26. <a-select-option v-for="item in typeList" :value="item.id" :key="item.id">
  27. <span v-if="item.id != 'all'">{{ item.productBrandName }} - {{ item.productTypeName3 }}</span>
  28. <span v-else>全部</span>
  29. </a-select-option>
  30. </a-select>
  31. </a-form-model-item>
  32. <a-form-model-item label="货位编号" prop="orderBy" v-if="nowType=='dbflPrint'">
  33. <a-radio-group v-model="form.orderBy">
  34. <a-radio value="ASC">打印(↑升序)</a-radio>
  35. <a-radio value="DESC">打印(↓降序)</a-radio>
  36. <a-radio value="-1">不打印</a-radio>
  37. </a-radio-group>
  38. </a-form-model-item>
  39. <a-form-model-item label="产品价格" prop="priceType" v-if="nowType=='dbPrint'||nowType=='dbExport'">
  40. <a-radio-group v-model="form.priceType">
  41. <a-radio value="ALLOCATE_BILL_PRICE">销售价</a-radio>
  42. <a-radio value="ALLOCATE_BILL_COST">成本价</a-radio>
  43. <a-radio value="ALLOCATE_BILL">不打印</a-radio>
  44. </a-radio-group>
  45. </a-form-model-item>
  46. </a-form-model>
  47. <div class="btn-cont">
  48. <a-button id="allocateBill-print-close" @click="handleClose('preview')">取消</a-button>
  49. <a-button
  50. v-if="nowType=='dbflPrint'||nowType=='dbPrint'"
  51. id="allocateBill-print-save"
  52. type="primary"
  53. class="button-info"
  54. @click="handleSave('preview')"
  55. style="margin-left: 15px;">打印预览</a-button>
  56. <a-button
  57. v-if="hidePrint&&(nowType=='dbflPrint'||nowType=='dbPrint')"
  58. type="primary"
  59. id="allocateBill-print-back"
  60. @click="handleSave('print')"
  61. style="margin-left: 15px;">确定打印</a-button>
  62. <a-button
  63. v-if="nowType=='dbflExport'||nowType=='dbExport'"
  64. type="primary"
  65. id="allocateBill-print-back"
  66. @click="handleSave('export')"
  67. style="margin-left: 15px;">确定导出</a-button>
  68. </div>
  69. </a-spin>
  70. </a-modal>
  71. </template>
  72. <script>
  73. import { allocateBillProductTypeList } from '@/api/allocateBill'
  74. export default {
  75. props: {
  76. openModal: { // 弹框显示状态
  77. type: Boolean,
  78. default: false
  79. },
  80. itemData: {
  81. type: Object,
  82. default: () => {
  83. return null
  84. }
  85. },
  86. nowType: {
  87. type: String,
  88. default: ''
  89. }
  90. },
  91. data () {
  92. return {
  93. isShow: this.openModal, // 是否打开弹框
  94. form: {
  95. id: 'all',
  96. priceType: undefined,
  97. orderBy: undefined
  98. },
  99. rules: {
  100. id: [{ required: true, message: '请选择产品分类', trigger: 'change' }],
  101. priceType: [{ required: true, message: '请选择产品价格', trigger: 'change' }],
  102. orderBy: [{ required: true, message: '请选择货位编号', trigger: 'change' }]
  103. },
  104. formItemLayout: {
  105. labelCol: { span: 6 },
  106. wrapperCol: { span: 16 }
  107. },
  108. spinning: false,
  109. typeList: []
  110. }
  111. },
  112. computed: {
  113. modalTit () {
  114. let title = ''
  115. if (this.nowType == 'dbPrint') {
  116. title = '调拨打印'
  117. } else if (this.nowType == 'dbflPrint') {
  118. title = '调拨分类打印'
  119. } else if (this.nowType == 'dbflExport') {
  120. title = '调拨分类导出'
  121. } else if (this.nowType == 'dbExport') {
  122. title = '导出Excel'
  123. }
  124. return title
  125. },
  126. hidePrint () {
  127. return this.itemData && this.itemData.printState && this.itemData.printState != 'UNABLE_PRINT' && this.itemData.printState != 'CANCEL_PRINT'
  128. }
  129. },
  130. methods: {
  131. // 确认
  132. handleSave (type) {
  133. const _this = this
  134. this.$refs.ruleForm.validate(valid => {
  135. if (valid) {
  136. let authCode = ''
  137. if (this.nowType == 'dbPrint') {
  138. authCode = 'B_transferOut_print'
  139. } else if (this.nowType == 'dbflPrint') {
  140. authCode = 'B_transferOutType_print'
  141. } else if (this.nowType == 'dbflExport') {
  142. authCode = 'B_transferOutType_export'
  143. } else if (this.nowType == 'dbExport') {
  144. authCode = 'B_transferOut_detail_export'
  145. }
  146. this.$store.state.app.curActionPermission = authCode
  147. // 普通打印/导出
  148. const obj = {
  149. allocateSn: _this.itemData.allocateSn,
  150. allocateNo: _this.itemData.allocateNo,
  151. printType: _this.form.priceType,
  152. isPreview: type == 'preview' ? 1 : 0
  153. }
  154. // 分类打印/导出
  155. if (_this.nowType == 'dbflPrint' || _this.nowType == 'dbflExport') {
  156. const item = _this.typeList.find(item => item.id == _this.form.id)
  157. if (item) {
  158. obj.productBrandSn = item.productBrandSn
  159. obj.productTypeSn3 = item.productTypeSn3
  160. obj.printType = 'ALLOCATE_BILL_TYPE'
  161. }
  162. // 打印货位编号
  163. if (_this.nowType == 'dbflPrint') {
  164. if (_this.form.orderBy != '-1') {
  165. obj.orderBy = _this.form.orderBy
  166. }
  167. }
  168. }
  169. // 打印
  170. if (_this.nowType == 'dbPrint' || _this.nowType == 'dbflPrint') {
  171. _this.$emit('ok', obj)
  172. } else {
  173. // 导出
  174. _this.$emit('export', obj)
  175. }
  176. _this.isShow = false
  177. } else {
  178. console.log('error submit!!')
  179. return false
  180. }
  181. })
  182. },
  183. // 获取该销售单产品二级分类
  184. getTypeData () {
  185. this.typeList = [{ id: 'all' }]
  186. allocateBillProductTypeList({ sn: this.itemData.allocateSn || null }).then(res => {
  187. if (res.status == 200) {
  188. if (res.data && res.data.length > 0) {
  189. this.typeList = [...this.typeList, ...res.data]
  190. }
  191. }
  192. })
  193. },
  194. handleClose () {
  195. this.$emit('close')
  196. this.$refs.ruleForm.resetFields()
  197. this.form = {
  198. id: 'all',
  199. priceType: undefined
  200. }
  201. }
  202. },
  203. watch: {
  204. // 父页面传过来的弹框状态
  205. openModal (newValue, oldValue) {
  206. this.isShow = newValue
  207. },
  208. // 重定义的弹框状态
  209. isShow (newValue, oldValue) {
  210. if (!newValue) {
  211. this.handleClose()
  212. } else {
  213. if (this.nowType == 'dbflPrint' || this.nowType == 'dbflExport') {
  214. this.getTypeData()
  215. }
  216. }
  217. }
  218. }
  219. }
  220. </script>
  221. <style lang="less">
  222. .allocateBill-print-type-modal{
  223. .btn-cont {
  224. text-align: center;
  225. margin: 35px 0 10px;
  226. }
  227. }
  228. </style>