chooseBillModal.vue 6.5 KB

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