printModal.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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-typeList" 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" id="allocateBill-print-orderBy">
  34. <a-radio value="ASC" id="allocateBill-print-orderBy-asc">打印(↑升序)</a-radio>
  35. <a-radio value="DESC" id="allocateBill-print-orderBy-desc">打印(↓降序)</a-radio>
  36. <a-radio value="-1" id="allocateBill-print-orderBy-1">不打印</a-radio>
  37. </a-radio-group>
  38. </a-form-model-item>
  39. <a-form-model-item label="产品价格" style="margin-bottom: 0;" prop="priceType" v-if="nowType=='dbPrint'">
  40. <a-radio-group v-model="form.priceType" id="allocateBill-print-priceType">
  41. <a-radio value="ALLOCATE_BILL_PRICE" id="allocateBill-print-priceType1" v-if="$hasPermissions('B_transferOut_print_salesPrice')">销售价</a-radio>
  42. <a-radio value="ALLOCATE_BILL_COST" id="allocateBill-print-priceType2" v-if="$hasPermissions('B_transferOut_print_costPrice')">成本价</a-radio>
  43. <a-radio value="ALLOCATE_BILL" id="allocateBill-print-priceType3">不打印</a-radio>
  44. </a-radio-group>
  45. </a-form-model-item>
  46. <a-form-model-item label="产品价格" style="margin-bottom: 0;" prop="priceType" v-if="nowType=='dbExport'">
  47. <a-radio-group v-model="form.priceType" id="allocateBill-print-priceType">
  48. <a-radio value="ALLOCATE_BILL_PRICE" id="allocateBill-print-priceType1" v-if="$hasPermissions('B_transferOut_detail_export_salesPrice')">销售价</a-radio>
  49. <a-radio value="ALLOCATE_BILL_COST" id="allocateBill-print-priceType2" v-if="$hasPermissions('B_transferOut_detail_export_costPrice')">成本价</a-radio>
  50. <a-radio value="ALLOCATE_BILL" id="allocateBill-print-priceType3">不导出</a-radio>
  51. </a-radio-group>
  52. </a-form-model-item>
  53. <a-form-model-item label="备注" v-if="nowType=='dbPrint'">
  54. <a-checkbox @change="onChangeRemark" :checked="remarkFlag" id="allocateBill-print-remark">
  55. 打印
  56. </a-checkbox>
  57. </a-form-model-item>
  58. </a-form-model>
  59. <div class="btn-cont">
  60. <a-button id="allocateBill-printcancel" @click="handleClose('preview')">取消</a-button>
  61. <a-button
  62. v-if="nowType=='dbflPrint'||nowType=='dbPrint'"
  63. id="allocateBill-print-dbflPrint"
  64. type="primary"
  65. class="button-info"
  66. @click="handleSave('preview')"
  67. style="margin-left: 15px;">打印预览</a-button>
  68. <a-button
  69. v-if="hidePrint&&(nowType=='dbflPrint'||nowType=='dbPrint')"
  70. type="primary"
  71. id="allocateBill-print-dbflPrint"
  72. @click="handleSave('print')"
  73. style="margin-left: 15px;">确定打印</a-button>
  74. <a-button
  75. v-if="nowType=='dbflExport'||nowType=='dbExport'"
  76. type="primary"
  77. id="allocateBill-print-export"
  78. @click="handleSave('export')"
  79. style="margin-left: 15px;">确定导出</a-button>
  80. </div>
  81. </a-spin>
  82. </a-modal>
  83. </template>
  84. <script>
  85. import { allocateBillProductTypeList } from '@/api/allocateBill'
  86. export default {
  87. props: {
  88. openModal: { // 弹框显示状态
  89. type: Boolean,
  90. default: false
  91. },
  92. itemData: {
  93. type: Object,
  94. default: () => {
  95. return null
  96. }
  97. },
  98. nowType: {
  99. type: String,
  100. default: ''
  101. }
  102. },
  103. data () {
  104. return {
  105. isShow: this.openModal, // 是否打开弹框
  106. // 提交参数
  107. form: {
  108. id: 'all', // 产品分类
  109. priceType: 'ALLOCATE_BILL', // 产品价格
  110. orderBy: undefined, // 排序
  111. remarkFlag: 1// 备货打印 1打印 0不打印
  112. },
  113. //
  114. remarkFlag: true, // 备货打印
  115. // 表单验证规则
  116. rules: {
  117. id: [{ required: true, message: '请选择产品分类', trigger: 'change' }],
  118. priceType: [{ required: true, message: '请选择产品价格', trigger: 'change' }],
  119. orderBy: [{ required: true, message: '请选择货位编号', trigger: 'change' }]
  120. },
  121. // form表单label布局
  122. formItemLayout: {
  123. labelCol: { span: 6 },
  124. wrapperCol: { span: 16 }
  125. },
  126. spinning: false,
  127. typeList: []// 产品分类列表数据
  128. }
  129. },
  130. computed: {
  131. // 弹窗标题
  132. modalTit () {
  133. let title = ''
  134. if (this.nowType == 'dbPrint') {
  135. title = '调拨打印'
  136. } else if (this.nowType == 'dbflPrint') {
  137. title = '调拨分类打印'
  138. } else if (this.nowType == 'dbflExport') {
  139. title = '调拨分类导出'
  140. } else if (this.nowType == 'dbExport') {
  141. title = '导出Excel'
  142. }
  143. return title
  144. },
  145. // 打印状态
  146. hidePrint () {
  147. return this.itemData && this.itemData.printState && this.itemData.printState != 'UNABLE_PRINT' && this.itemData.printState != 'CANCEL_PRINT'
  148. }
  149. },
  150. methods: {
  151. // 打印
  152. onChangeRemark (e) {
  153. this.remarkFlag = e.target.checked
  154. this.form.remarkFlag = e.target.checked ? 1 : 0
  155. },
  156. // 确认
  157. handleSave (type) {
  158. const _this = this
  159. this.$refs.ruleForm.validate(valid => {
  160. if (valid) {
  161. let authCode = ''
  162. if (this.nowType == 'dbPrint') {
  163. authCode = 'B_transferOut_print'
  164. } else if (this.nowType == 'dbflPrint') {
  165. authCode = 'B_transferOutType_print'
  166. } else if (this.nowType == 'dbflExport') {
  167. authCode = 'B_transferOutType_export'
  168. } else if (this.nowType == 'dbExport') {
  169. authCode = 'B_transferOut_detail_export'
  170. }
  171. this.$store.state.app.curActionPermission = authCode
  172. // 普通打印/导出
  173. const obj = {
  174. allocateSn: _this.itemData.allocateSn,
  175. allocateNo: _this.itemData.allocateNo,
  176. printType: _this.form.priceType,
  177. isPreview: type == 'preview' ? 1 : 0
  178. }
  179. // 分类打印/导出
  180. if (_this.nowType == 'dbflPrint' || _this.nowType == 'dbflExport') {
  181. const item = _this.typeList.find(item => item.id == _this.form.id)
  182. if (item) {
  183. obj.productBrandSn = item.productBrandSn
  184. obj.productTypeSn3 = item.productTypeSn3
  185. obj.printType = 'ALLOCATE_BILL_TYPE'
  186. }
  187. // 打印货位编号
  188. if (_this.nowType == 'dbflPrint') {
  189. if (_this.form.orderBy != '-1') {
  190. obj.orderBy = _this.form.orderBy
  191. }
  192. }
  193. }
  194. // 打印
  195. if (this.nowType == 'dbPrint') {
  196. obj.remarkFlag = this.form.remarkFlag
  197. }
  198. if (_this.nowType == 'dbPrint' || _this.nowType == 'dbflPrint') {
  199. _this.$emit('ok', obj)
  200. } else {
  201. // 导出
  202. _this.$emit('export', obj)
  203. }
  204. _this.isShow = false
  205. } else {
  206. console.log('error submit!!')
  207. return false
  208. }
  209. })
  210. },
  211. // 获取该销售单产品二级分类
  212. getTypeData () {
  213. this.typeList = [{ id: 'all' }]
  214. allocateBillProductTypeList({ sn: this.itemData.allocateSn || null }).then(res => {
  215. if (res.status == 200) {
  216. if (res.data && res.data.length > 0) {
  217. this.typeList = [...this.typeList, ...res.data]
  218. }
  219. }
  220. })
  221. },
  222. // 关闭
  223. handleClose () {
  224. this.$emit('close')
  225. this.$refs.ruleForm.resetFields()
  226. this.form = {
  227. id: 'all',
  228. priceType: 'ALLOCATE_BILL',
  229. remarkFlag: 1
  230. }
  231. this.remarkFlag = true
  232. }
  233. },
  234. watch: {
  235. // 父页面传过来的弹框状态
  236. openModal (newValue, oldValue) {
  237. this.isShow = newValue
  238. },
  239. // 重定义的弹框状态
  240. isShow (newValue, oldValue) {
  241. if (!newValue) {
  242. this.handleClose()
  243. } else {
  244. if (this.nowType == 'dbflPrint' || this.nowType == 'dbflExport') {
  245. this.getTypeData()
  246. }
  247. }
  248. }
  249. }
  250. }
  251. </script>
  252. <style lang="less">
  253. .allocateBill-print-type-modal{
  254. .btn-cont {
  255. text-align: center;
  256. margin: 35px 0 10px;
  257. }
  258. }
  259. </style>