selectXtModal.vue 7.2 KB

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