chooseBillModal.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <a-modal
  3. centered
  4. class="chooseBillModal-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="全部单据"
  8. v-model="isShow"
  9. @cancle="isShow=false"
  10. :width="960">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <!-- 搜索条件 -->
  13. <div class="table-page-search-wrapper">
  14. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  15. <a-row :gutter="15">
  16. <a-col :md="6" :sm="24">
  17. <a-form-item label="单据号">
  18. <a-input id="chooseBillModal-bizNo" v-model.trim="queryParam.bizNo" allowClear placeholder="请输入单据号"/>
  19. </a-form-item>
  20. </a-col>
  21. <a-col :md="6" :sm="24">
  22. <a-form-item label="单据类型">
  23. <v-select
  24. v-model="queryParam.bizType"
  25. ref="bizType"
  26. id="chooseBillModal-bizType"
  27. code="SETTLE_BIZ_TYPE"
  28. placeholder="请选择单据类型"
  29. allowClear></v-select>
  30. </a-form-item>
  31. </a-col>
  32. <a-col :md="7" :sm="24">
  33. <a-form-item label="审核时间">
  34. <rangeDate ref="rangeDate" @change="dateChange" />
  35. </a-form-item>
  36. </a-col>
  37. <a-col :md="5" :sm="24">
  38. <a-button style="margin-bottom: 18px;" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="chooseBillModal-refresh">查询</a-button>
  39. <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="chooseBillModal-reset">重置</a-button>
  40. </a-col>
  41. </a-row>
  42. </a-form>
  43. </div>
  44. <!-- 列表 -->
  45. <s-table
  46. class="sTable"
  47. ref="table"
  48. size="small"
  49. :rowKey="(record) => record.id"
  50. :row-selection="{ columnWidth: 40 }"
  51. @rowSelection="rowSelectionFun"
  52. :columns="columns"
  53. :data="loadData"
  54. :showPagination="false"
  55. :scroll="{ y: 400 }"
  56. :defaultLoadData="false"
  57. bordered>
  58. </s-table>
  59. <div class="btn-cont">
  60. <a-button type="primary" id="chooseBillModal-modal-save" @click="handleSave">确定</a-button>
  61. <a-button id="chooseBillModal-modal-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
  62. </div>
  63. </a-spin>
  64. </a-modal>
  65. </template>
  66. <script>
  67. import { commonMixin } from '@/utils/mixin'
  68. import { STable, VSelect } from '@/components'
  69. import rangeDate from '@/views/common/rangeDate.vue'
  70. import { settleInfoAllList } from '@/api/settle'
  71. export default {
  72. name: 'ChooseBillModal',
  73. components: { STable, VSelect, rangeDate },
  74. mixins: [commonMixin],
  75. props: {
  76. openModal: { // 弹框显示状态
  77. type: Boolean,
  78. default: false
  79. },
  80. nowChoose: {
  81. type: Array,
  82. default: () => {
  83. return []
  84. }
  85. },
  86. settleClientSn: {
  87. type: String,
  88. default: ''
  89. }
  90. },
  91. data () {
  92. return {
  93. spinning: false,
  94. isShow: this.openModal, // 是否打开弹框
  95. disabled: false,
  96. queryParam: {
  97. auditBeginDate: '',
  98. auditEndDate: '',
  99. bizNo: '',
  100. bizType: undefined
  101. },
  102. allData: [],
  103. // 表头
  104. columns: [
  105. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  106. { title: '单据号', dataIndex: 'bizNo', width: '28%', align: 'center', customRender: function (text) { return text || '--' } },
  107. { title: '单据类型', dataIndex: 'bizTypeDictValue', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  108. { title: '审核时间', dataIndex: 'auditTime', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  109. { title: '金额', dataIndex: 'totalAmount', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  110. { title: '余额', dataIndex: 'unsettleAmount', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  111. ],
  112. // 加载数据方法 必须为 Promise 对象
  113. loadData: parameter => {
  114. this.disabled = true
  115. this.spinning = true
  116. return settleInfoAllList(Object.assign(this.queryParam, { settleClientSn: this.settleClientSn, notEqZero: 1 })).then(res => {
  117. let data
  118. if (res.status == 200) {
  119. data = res.data
  120. const selectedRowKeys = []
  121. const selectedRows = []
  122. for (var i = 0; i < data.length; i++) {
  123. data[i].no = i + 1
  124. data[i].settleAmount = data[i].unsettleAmount
  125. const ind = this.nowChoose.findIndex(item => item.id == data[i].id)
  126. if (ind != -1) {
  127. selectedRowKeys.push(data[i].id)
  128. selectedRows.push(data[i])
  129. }
  130. }
  131. this.$refs.table.setTableSelected(selectedRowKeys, selectedRows) // 设置表格选中项
  132. this.disabled = false
  133. }
  134. this.spinning = false
  135. return data
  136. })
  137. },
  138. rowSelectionInfo: null
  139. }
  140. },
  141. methods: {
  142. // 表格选中项
  143. rowSelectionFun (obj) {
  144. this.rowSelectionInfo = obj || null
  145. },
  146. // 时间 change
  147. dateChange (date) {
  148. this.queryParam.auditBeginDate = date[0]
  149. this.queryParam.auditEndDate = date[1]
  150. },
  151. // 确定
  152. handleSave () {
  153. this.$emit('ok', this.rowSelectionInfo && this.rowSelectionInfo.selectedRows)
  154. this.isShow = false
  155. },
  156. // 重置
  157. resetSearchForm () {
  158. this.$refs.rangeDate.resetDate()
  159. this.queryParam.auditBeginDate = ''
  160. this.queryParam.auditEndDate = ''
  161. this.queryParam.bizNo = ''
  162. this.queryParam.bizType = undefined
  163. this.$refs.table.refresh(true)
  164. }
  165. },
  166. watch: {
  167. // 父页面传过来的弹框状态
  168. openModal (newValue, oldValue) {
  169. this.isShow = newValue
  170. },
  171. // 重定义的弹框状态
  172. isShow (newValue, oldValue) {
  173. const _this = this
  174. if (!newValue) {
  175. _this.$emit('close')
  176. _this.$refs.table.clearSelected() // 清空表格选中项
  177. _this.resetSearchForm()
  178. } else {
  179. setTimeout(() => {
  180. _this.$refs.table.refresh(true)
  181. }, 200)
  182. }
  183. }
  184. }
  185. }
  186. </script>
  187. <style lang="less">
  188. .chooseBillModal-modal{
  189. .btn-cont {
  190. text-align: center;
  191. margin: 35px 0 10px;
  192. }
  193. }
  194. </style>