selectXtModal.vue 6.4 KB

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