selectXtModal.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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. :defaultLoadData="false"
  48. bordered>
  49. <!-- 收款单号 -->
  50. <template slot="salesReturnBillNo" slot-scope="text, record">
  51. {{ record.salesReturnBillNo }}
  52. </template>
  53. <!-- 操作 -->
  54. <template slot="action" slot-scope="text, record">
  55. <div v-if="record.billStatus == 'WAIT_RECEIVE'">
  56. <a-button
  57. size="small"
  58. type="link"
  59. class="button-warning"
  60. v-if="!record.checked"
  61. @click="handleChoose(record)"
  62. >选择</a-button>
  63. <span style="color:green;" v-else>已选</span>
  64. </div>
  65. <span v-else>--</span>
  66. </template>
  67. </s-table>
  68. </div>
  69. </a-spin>
  70. </a-modal>
  71. </template>
  72. <script>
  73. import { STable, VSelect } from '@/components'
  74. import { salesReturnList } from '@/api/salesReturn'
  75. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  76. export default {
  77. name: 'GlDetailModal',
  78. components: { STable, VSelect, dealerSubareaScopeList },
  79. props: {
  80. openModal: { // 弹框显示状态
  81. type: Boolean,
  82. default: false
  83. },
  84. modalTit: { // 弹框标题
  85. type: String,
  86. default: null
  87. },
  88. chooseData: {
  89. type: Array,
  90. default: function () {
  91. return []
  92. }
  93. },
  94. warehouseSn: {
  95. type: String,
  96. default: null
  97. }
  98. },
  99. data () {
  100. return {
  101. isShow: this.openModal, // 是否打开弹框
  102. disabled: false,
  103. spinning: false,
  104. handlePlData: [],
  105. queryParam: {
  106. salesReturnBillNo: '',
  107. buyerSn: undefined
  108. },
  109. columns: [
  110. { title: '序号', dataIndex: 'no', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  111. { title: '总部销退单号', scopedSlots: { customRender: 'salesReturnBillNo' }, width: '15%', align: 'center' },
  112. { title: '客户名称', dataIndex: 'buyerName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  113. { title: '申请退货数量', dataIndex: 'totalInitialQty', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  114. { title: '审核时间', dataIndex: 'auditTime', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  115. { title: '业务状态', dataIndex: 'billStatusDictValue', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  116. { title: '操作', scopedSlots: { customRender: 'action' }, width: '12%', align: 'center' }
  117. ],
  118. orginData: [],
  119. // 加载数据方法 必须为 Promise 对象
  120. loadData: parameter => {
  121. this.disabled = true
  122. this.spinning = true
  123. this.queryParam.warehouseSn = this.warehouseSn
  124. return salesReturnList(Object.assign(parameter, this.queryParam),1).then(res => {
  125. let data
  126. if (res.status == 200) {
  127. data = res.data
  128. const no = (data.pageNo - 1) * data.pageSize
  129. for (var i = 0; i < data.list.length; i++) {
  130. data.list[i].no = no + i + 1
  131. const index = this.chooseData.findIndex(item => data.list[i].salesReturnBillNo == item.salesReturnBillNo)
  132. data.list[i].checked = index >= 0
  133. }
  134. this.disabled = false
  135. }
  136. this.spinning = false
  137. this.orginData = data.list
  138. return data
  139. })
  140. },
  141. snList: []
  142. }
  143. },
  144. computed: {
  145. totalAmount () {
  146. let ret = 0
  147. this.handlePlData.map(item => {
  148. ret = ret + item.totalAmount
  149. })
  150. return ret.toFixed(2)
  151. }
  152. },
  153. methods: {
  154. custChange (val) {
  155. this.queryParam.buyerSn = val.key
  156. },
  157. // 删除
  158. handleDel (row) {
  159. const i = this.chooseData.findIndex(item => row.salesReturnBillNo == item.salesReturnBillNo)
  160. this.chooseData.splice(i, 1)
  161. const oi = this.orginData.findIndex(item => row.salesReturnBillNo == item.salesReturnBillNo)
  162. if (oi >= 0) {
  163. this.orginData[oi].checked = false
  164. }
  165. },
  166. // 选择
  167. handleChoose (row) {
  168. row.checked = true
  169. this.chooseData.push(row)
  170. },
  171. // 取消
  172. handleCommonCancel () {
  173. this.$emit('cancel')
  174. },
  175. // 重置
  176. resetSearchForm () {
  177. this.queryParam = {
  178. salesReturnBillNo: '',
  179. buyerSn: undefined
  180. }
  181. this.orginData = []
  182. this.$nextTick(() => {
  183. this.$refs.dealerSubareaScopeList.resetForm()
  184. this.$refs.table.refresh(true)
  185. })
  186. }
  187. },
  188. watch: {
  189. // 父页面传过来的弹框状态
  190. openModal (newValue, oldValue) {
  191. this.isShow = newValue
  192. },
  193. // 重定义的弹框状态
  194. isShow (newValue, oldValue) {
  195. if (!newValue) {
  196. this.handleCommonCancel()
  197. } else {
  198. this.resetSearchForm()
  199. }
  200. }
  201. }
  202. }
  203. </script>
  204. <style lang="less">
  205. </style>