printModal.vue 11 KB

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