chooseBillModal.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <a-modal
  3. centered
  4. class="chooseBillModal-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="全部单据"
  8. v-model="isShow"
  9. @cancel="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. settleClientType: {
  91. type: String,
  92. default: ''
  93. }
  94. },
  95. data () {
  96. return {
  97. spinning: false,
  98. isShow: this.openModal, // 是否打开弹框
  99. disabled: false,
  100. queryParam: {
  101. auditBeginDate: '',
  102. auditEndDate: '',
  103. bizNo: '',
  104. bizType: undefined
  105. },
  106. allData: [],
  107. // 表头
  108. columns: [
  109. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  110. { title: '单据号', dataIndex: 'bizNo', width: '28%', align: 'center', customRender: function (text) { return text || '--' } },
  111. { title: '单据类型', dataIndex: 'bizTypeDictValue', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  112. { title: '审核时间', dataIndex: 'auditTime', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  113. { title: '金额', dataIndex: 'totalAmount', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  114. { title: '余额', dataIndex: 'unsettleAmount', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  115. ],
  116. // 加载数据方法 必须为 Promise 对象
  117. loadData: parameter => {
  118. this.disabled = true
  119. this.spinning = true
  120. return settleInfoAllList(Object.assign(this.queryParam, { settleClientType: this.settleClientType, settleClientSn: this.settleClientSn, notEqZero: 1 })).then(res => {
  121. let data
  122. if (res.status == 200) {
  123. data = res.data
  124. const selectedRowKeys = []
  125. const selectedRows = []
  126. for (var i = 0; i < data.length; i++) {
  127. data[i].no = i + 1
  128. data[i].settleAmount = data[i].unsettleAmount
  129. const ind = this.nowChoose.findIndex(item => item.id == data[i].id)
  130. if (ind != -1) {
  131. selectedRowKeys.push(data[i].id)
  132. selectedRows.push(data[i])
  133. }
  134. }
  135. this.$refs.table.setTableSelected(selectedRowKeys, selectedRows) // 设置表格选中项
  136. this.disabled = false
  137. }
  138. this.spinning = false
  139. return data
  140. })
  141. },
  142. rowSelectionInfo: null
  143. }
  144. },
  145. methods: {
  146. // 表格选中项
  147. rowSelectionFun (obj) {
  148. this.rowSelectionInfo = obj || null
  149. },
  150. // 时间 change
  151. dateChange (date) {
  152. this.queryParam.auditBeginDate = date[0]
  153. this.queryParam.auditEndDate = date[1]
  154. },
  155. // 确定
  156. handleSave () {
  157. this.$emit('ok', this.rowSelectionInfo && this.rowSelectionInfo.selectedRows)
  158. this.isShow = false
  159. },
  160. // 重置
  161. resetSearchForm () {
  162. this.$refs.rangeDate.resetDate()
  163. this.queryParam.auditBeginDate = ''
  164. this.queryParam.auditEndDate = ''
  165. this.queryParam.bizNo = ''
  166. this.queryParam.bizType = undefined
  167. this.$refs.table.refresh(true)
  168. }
  169. },
  170. watch: {
  171. // 父页面传过来的弹框状态
  172. openModal (newValue, oldValue) {
  173. this.isShow = newValue
  174. },
  175. // 重定义的弹框状态
  176. isShow (newValue, oldValue) {
  177. const _this = this
  178. if (!newValue) {
  179. _this.$emit('close')
  180. _this.$refs.table.clearSelected() // 清空表格选中项
  181. _this.resetSearchForm()
  182. } else {
  183. setTimeout(() => {
  184. _this.$refs.table.refresh(true)
  185. }, 200)
  186. }
  187. }
  188. }
  189. }
  190. </script>
  191. <style lang="less">
  192. .chooseBillModal-modal{
  193. .btn-cont {
  194. text-align: center;
  195. margin: 35px 0 10px;
  196. }
  197. }
  198. </style>