printModal.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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'">
  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="priceType" v-if="nowType=='dbPrint'">
  33. <a-radio-group v-model="form.priceType">
  34. <a-radio value="ALLOCATE_BILL_PRICE">销售价</a-radio>
  35. <a-radio value="ALLOCATE_BILL_COST">成本价</a-radio>
  36. <a-radio value="ALLOCATE_BILL">不打印</a-radio>
  37. </a-radio-group>
  38. </a-form-model-item>
  39. </a-form-model>
  40. <div class="btn-cont">
  41. <a-button id="allocateBill-print-close" @click="handleClose('preview')">取消</a-button>
  42. <a-button id="allocateBill-print-save" @click="handleSave('preview')" style="margin-left: 15px;">打印预览</a-button>
  43. <a-button type="primary" id="allocateBill-print-back" @click="handleSave('print')" style="margin-left: 15px;">确定打印</a-button>
  44. </div>
  45. </a-spin>
  46. </a-modal>
  47. </template>
  48. <script>
  49. import { allocateBillProductTypeList } from '@/api/allocateBill'
  50. export default {
  51. props: {
  52. openModal: { // 弹框显示状态
  53. type: Boolean,
  54. default: false
  55. },
  56. itemData: {
  57. type: Object,
  58. default: () => {
  59. return null
  60. }
  61. },
  62. nowType: {
  63. type: String,
  64. default: ''
  65. }
  66. },
  67. data () {
  68. return {
  69. isShow: this.openModal, // 是否打开弹框
  70. form: {
  71. id: 'all',
  72. priceType: undefined
  73. },
  74. rules: {
  75. id: [{ required: true, message: '请选择产品分类', trigger: 'change' }],
  76. priceType: [{ required: true, message: '请选择产品价格', trigger: 'change' }]
  77. },
  78. formItemLayout: {
  79. labelCol: { span: 6 },
  80. wrapperCol: { span: 16 }
  81. },
  82. spinning: false,
  83. typeList: []
  84. }
  85. },
  86. computed: {
  87. modalTit () {
  88. let title = ''
  89. if (this.nowType == 'dbPrint') {
  90. title = '调拨打印'
  91. } else if (this.nowType == 'dbflPrint') {
  92. title = '调拨分类打印'
  93. }
  94. return title
  95. }
  96. },
  97. methods: {
  98. // 确认
  99. handleSave (type) {
  100. const _this = this
  101. this.$refs.ruleForm.validate(valid => {
  102. if (valid) {
  103. if (_this.nowType == 'dbflPrint') {
  104. const item = _this.typeList.find(item => item.id == _this.form.id)
  105. if (item) {
  106. const obj = {
  107. allocateSn: _this.itemData.allocateSn,
  108. allocateNo: _this.itemData.allocateNo,
  109. productBrandSn: item.productBrandSn,
  110. productTypeSn3: item.productTypeSn3,
  111. printType: 'ALLOCATE_BILL_TYPE',
  112. isPreview: type == 'preview' ? 1 : 0
  113. }
  114. _this.$emit('ok', obj)
  115. }
  116. } else {
  117. const obj = {
  118. allocateSn: _this.itemData.allocateSn,
  119. allocateNo: _this.itemData.allocateNo,
  120. printType: _this.form.priceType,
  121. isPreview: type == 'preview' ? 1 : 0
  122. }
  123. _this.$emit('ok', obj)
  124. }
  125. _this.isShow = false
  126. } else {
  127. console.log('error submit!!')
  128. return false
  129. }
  130. })
  131. },
  132. // 获取该销售单产品二级分类
  133. getTypeData () {
  134. this.typeList = [{ id: 'all' }]
  135. allocateBillProductTypeList({ sn: this.itemData.allocateSn || null }).then(res => {
  136. if (res.status == 200) {
  137. if (res.data && res.data.length > 0) {
  138. this.typeList = [...this.typeList, ...res.data]
  139. }
  140. }
  141. })
  142. },
  143. handleClose () {
  144. this.$emit('close')
  145. this.$refs.ruleForm.resetFields()
  146. this.form = {
  147. id: 'all',
  148. priceType: undefined
  149. }
  150. }
  151. },
  152. watch: {
  153. // 父页面传过来的弹框状态
  154. openModal (newValue, oldValue) {
  155. this.isShow = newValue
  156. },
  157. // 重定义的弹框状态
  158. isShow (newValue, oldValue) {
  159. if (!newValue) {
  160. this.handleClose()
  161. } else {
  162. if (this.nowType == 'dbflPrint') {
  163. this.getTypeData()
  164. }
  165. }
  166. }
  167. }
  168. }
  169. </script>
  170. <style lang="less">
  171. .allocateBill-print-type-modal{
  172. .btn-cont {
  173. text-align: center;
  174. margin: 35px 0 10px;
  175. }
  176. }
  177. </style>