chooseBillModal.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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="80%">
  11. <!-- 搜索条件 -->
  12. <div class="table-page-search-wrapper">
  13. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  14. <a-row :gutter="15">
  15. <a-col :md="6" :sm="24">
  16. <a-form-item label="单据号">
  17. <a-input id="chooseBillModal-bizNo" v-model.trim="queryParam.bizNo" allowClear placeholder="请输入单据号"/>
  18. </a-form-item>
  19. </a-col>
  20. <a-col :md="6" :sm="24">
  21. <a-form-item label="单据类型">
  22. <v-select
  23. v-model="queryParam.bizType"
  24. ref="bizType"
  25. id="chooseBillModal-bizType"
  26. code="SETTLE_BIZ_TYPE"
  27. placeholder="请选择单据类型"
  28. allowClear></v-select>
  29. </a-form-item>
  30. </a-col>
  31. <a-col :md="6" :sm="24">
  32. <a-form-item label="审核时间">
  33. <a-range-picker
  34. style="width:100%"
  35. id="chooseBillModal-auditTime"
  36. :disabledDate="disabledDate"
  37. v-model="auditTime"
  38. :format="dateFormat"
  39. :placeholder="['开始时间', '结束时间']" />
  40. </a-form-item>
  41. </a-col>
  42. <a-col :md="6" :sm="24">
  43. <a-button style="margin-bottom: 18px;" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="chooseBillModal-refresh">查询</a-button>
  44. <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="chooseBillModal-reset">重置</a-button>
  45. </a-col>
  46. </a-row>
  47. </a-form>
  48. </div>
  49. <!-- 列表 -->
  50. <s-table
  51. class="sTable"
  52. ref="table"
  53. size="small"
  54. :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
  55. :rowKey="(record) => record.id"
  56. :columns="columns"
  57. :data="loadData"
  58. :showPagination="false"
  59. :scroll="{ x: '100%', y: 400 }"
  60. :defaultLoadData="false"
  61. bordered>
  62. </s-table>
  63. <div class="btn-cont">
  64. <a-button type="primary" id="chooseBillModal-modal-save" @click="handleSave">确定</a-button>
  65. <a-button id="chooseBillModal-modal-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
  66. </div>
  67. </a-modal>
  68. </template>
  69. <script>
  70. import moment from 'moment'
  71. import { STable, VSelect } from '@/components'
  72. import { settleInfoAllList } from '@/api/settle'
  73. export default {
  74. name: 'ChooseBillModal',
  75. components: { STable, VSelect },
  76. props: {
  77. openModal: { // 弹框显示状态
  78. type: Boolean,
  79. default: false
  80. },
  81. nowChoose: {
  82. type: Array,
  83. default: () => {
  84. return []
  85. }
  86. },
  87. settleClientSn: {
  88. type: String,
  89. default: ''
  90. }
  91. },
  92. data () {
  93. return {
  94. isShow: this.openModal, // 是否打开弹框
  95. disabled: false,
  96. auditTime: [], // 审核时间
  97. dateFormat: 'YYYY-MM-DD',
  98. queryParam: {
  99. bizNo: '',
  100. bizType: undefined
  101. },
  102. // 表头
  103. columns: [
  104. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  105. { title: '单据号', dataIndex: 'bizNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  106. { title: '单据类型', dataIndex: 'bizTypeDictValue', align: 'center', customRender: function (text) { return text || '--' } },
  107. { title: '审核时间', dataIndex: 'auditTime', align: 'center', customRender: function (text) { return text || '--' } },
  108. { title: '金额', dataIndex: 'totalAmount', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  109. { title: '余额', dataIndex: 'unsettleAmount', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  110. ],
  111. // 加载数据方法 必须为 Promise 对象
  112. loadData: parameter => {
  113. this.disabled = true
  114. // 审核时间
  115. if (this.auditTime && this.auditTime.length > 0) {
  116. this.queryParam.auditBeginDate = moment(this.auditTime[0]).format(this.dateFormat) + '00:00:00'
  117. this.queryParam.auditEndDate = moment(this.auditTime[1]).format(this.dateFormat) + '23:59:59'
  118. } else {
  119. this.queryParam.auditBeginDate = undefined
  120. this.queryParam.auditEndDate = undefined
  121. }
  122. return settleInfoAllList(Object.assign(this.queryParam, { settleClientSn: this.settleClientSn })).then(res => {
  123. const data = res.data
  124. this.selectedRowKeys = []
  125. this.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. this.selectedRowKeys.push(data[i].id)
  132. this.selectedRows.push(data[i])
  133. }
  134. }
  135. this.disabled = false
  136. return data
  137. })
  138. },
  139. selectedRowKeys: [],
  140. selectedRows: []
  141. }
  142. },
  143. computed: {
  144. hasSelected () {
  145. return this.selectedRowKeys.length > 0
  146. }
  147. },
  148. methods: {
  149. // 不可选日期
  150. disabledDate (date, dateStrings) {
  151. return date && date.valueOf() > Date.now()
  152. },
  153. // 确定
  154. handleSave () {
  155. this.$emit('ok', this.selectedRows)
  156. this.isShow = false
  157. },
  158. // 重置
  159. resetSearchForm () {
  160. this.queryParam.bizNo = ''
  161. this.queryParam.bizType = undefined
  162. this.auditTime = []
  163. },
  164. onSelectChange (selectedRowKeys, selectedRows) {
  165. console.log('selectedRowKeys changed: ', selectedRowKeys, selectedRows)
  166. this.selectedRowKeys = selectedRowKeys
  167. this.selectedRows = selectedRows
  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.selectedRowKeys = []
  181. _this.selectedRows = []
  182. _this.resetSearchForm()
  183. } else {
  184. setTimeout(() => {
  185. _this.$refs.table.refresh(true)
  186. }, 200)
  187. }
  188. }
  189. }
  190. }
  191. </script>
  192. <style lang="less">
  193. .chooseBillModal-modal{
  194. .btn-cont {
  195. text-align: center;
  196. margin: 35px 0 10px;
  197. }
  198. }
  199. </style>