uniqueCodeModal.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <a-modal
  3. centered
  4. class="unique-code-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. v-model="isShow"
  8. :title="modalTit"
  9. @cancel="isShow=false"
  10. width="70%">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <div class="common-main">
  13. <!-- 搜索条件 -->
  14. <div ref="tableSearch" class="table-page-search-wrapper">
  15. <a-form layout="inline">
  16. <a-row :gutter="15">
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="产品编码">
  19. <a-input v-model.trim="queryParam.outBizSubNo" allowClear placeholder="请输入产品编码"/>
  20. </a-form-item>
  21. </a-col>
  22. <a-col :md="6" :sm="24">
  23. <a-form-item label="唯一码">
  24. <a-input v-model.trim="queryParam.demanderName" allowClear placeholder="请输入唯一码"/>
  25. </a-form-item>
  26. </a-col>
  27. <a-col :md="6" :sm="24">
  28. <a-form-item label="产品名称">
  29. <a-input v-model.trim="queryParam.demanderName" allowClear placeholder="请输入产品名称"/>
  30. </a-form-item>
  31. </a-col>
  32. <a-col :md="6" :sm="24">
  33. <span class="table-page-search-submitButtons">
  34. <a-button type="primary" :disabled="disabled" @click="$refs.table.refresh(true)">查询</a-button>
  35. <a-button style="margin-left: 8px" :disabled="disabled" @click="resetSearchForm()">重置</a-button>
  36. </span>
  37. </a-col>
  38. </a-row>
  39. </a-form>
  40. </div>
  41. <a-alert type="info" style="margin-bottom: 10px;" v-if="detailData!=null">
  42. <div slot="message">
  43. <span v-if="$route.params.type!='stockOut'">
  44. 轮胎款数:<strong>{{ detailData&&(detailData.totalSalesQty || detailData.totalSalesQty==0) ? detailData.totalSalesQty : '--' }}</strong>;
  45. </span>
  46. 轮胎总数量:<strong>{{ detailData&&(detailData.totalQty || detailData.totalQty==0) ? detailData.totalQty : '--' }}</strong>;
  47. </div>
  48. </a-alert>
  49. <!-- 表格数据 -->
  50. <s-table
  51. class="sTable"
  52. ref="table"
  53. size="small"
  54. :rowKey="(record) => record.id"
  55. :columns="columns"
  56. :data="loadData"
  57. :scroll="{ y: 400 }"
  58. :pageSize="10"
  59. bordered>
  60. </s-table>
  61. </div>
  62. </a-spin>
  63. </a-modal>
  64. </template>
  65. <script>
  66. import { commonMixin } from '@/utils/mixin'
  67. import { STable } from '@/components'
  68. import { stockOutList } from '@/api/stockOut'
  69. export default {
  70. name: 'UniqueCodeModal',
  71. mixins: [commonMixin],
  72. components: { STable },
  73. props: {
  74. openModal: { // 弹框显示状态
  75. type: Boolean,
  76. default: false
  77. },
  78. modalTit: { // 弹框标题
  79. type: String,
  80. default: null
  81. },
  82. chooseData: {
  83. type: Array,
  84. default: function () {
  85. return []
  86. }
  87. }
  88. },
  89. data () {
  90. return {
  91. isShow: this.openModal, // 是否打开弹框
  92. disabled: false,
  93. spinning: false,
  94. handlePlData: [],
  95. queryParam: {
  96. outBizSubNo: '',
  97. demanderName: '',
  98. receiverSn: undefined,
  99. warehouseSn: undefined,
  100. outBizTypeList: ['SALES', 'ALLOCATE']
  101. },
  102. orginData: [],
  103. // 加载数据方法 必须为 Promise 对象
  104. loadData: parameter => {
  105. this.disabled = true
  106. this.spinning = true
  107. return stockOutList(Object.assign(parameter, this.queryParam)).then(res => {
  108. let data
  109. if (res.status == 200) {
  110. data = res.data
  111. const no = (data.pageNo - 1) * data.pageSize
  112. for (var i = 0; i < data.list.length; i++) {
  113. data.list[i].no = no + i + 1
  114. const index = this.chooseData.findIndex(item => data.list[i].stockOutSn == item.stockOutSn)
  115. data.list[i].checked = index >= 0
  116. }
  117. this.disabled = false
  118. }
  119. this.spinning = false
  120. this.orginData = data.list
  121. return data
  122. })
  123. },
  124. snList: [],
  125. columns: [
  126. { title: '序号', dataIndex: 'no', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  127. { title: '产品编码', dataIndex: 'stockOutNo', width: '25%', align: 'center' },
  128. { title: '唯一码', dataIndex: 'outBizSubNo', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
  129. { title: '产品名称', dataIndex: 'demanderName', width: '50%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true }
  130. ],
  131. detailData: null
  132. }
  133. },
  134. methods: {
  135. custChange (val) {
  136. this.queryParam.receiverSn = val.key || ''
  137. },
  138. // 删除
  139. handleDel (row) {
  140. const i = this.chooseData.findIndex(item => row.stockOutSn == item.stockOutSn)
  141. this.chooseData.splice(i, 1)
  142. const oi = this.orginData.findIndex(item => row.stockOutSn == item.stockOutSn)
  143. if (oi >= 0) {
  144. this.orginData[oi].checked = false
  145. }
  146. },
  147. // 选择
  148. handleChoose (row) {
  149. row.checked = true
  150. this.chooseData.push(row)
  151. this.$emit('choose')
  152. },
  153. // 取消
  154. handleCommonCancel () {
  155. this.$emit('cancel')
  156. },
  157. // 重置
  158. resetSearchForm () {
  159. this.queryParam = {
  160. outBizSubNo: '',
  161. demanderName: '',
  162. receiverSn: undefined,
  163. warehouseSn: undefined,
  164. outBizTypeList: ['SALES', 'ALLOCATE']
  165. }
  166. this.orginData = []
  167. this.$nextTick(() => {
  168. this.$refs.dealerSubareaScopeList.resetForm()
  169. })
  170. if (this.$refs.table) {
  171. this.$refs.table.refresh(true)
  172. }
  173. }
  174. },
  175. watch: {
  176. // 父页面传过来的弹框状态
  177. openModal (newValue, oldValue) {
  178. this.isShow = newValue
  179. },
  180. // 重定义的弹框状态
  181. isShow (newValue, oldValue) {
  182. if (!newValue) {
  183. this.handleCommonCancel()
  184. } else {
  185. this.resetSearchForm()
  186. }
  187. }
  188. }
  189. }
  190. </script>
  191. <style lang="less">
  192. </style>