chooseBillModal.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <a-drawer
  3. title="全部单据"
  4. placement="right"
  5. class="chooseBillModal-new-modal jg-page-wrap"
  6. :visible="isShow"
  7. @close="isShow=false"
  8. width="70%"
  9. :get-container="false"
  10. :wrap-style="{ position: 'absolute' }">
  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="7" :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="7" :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="10" :sm="24">
  33. <a-form-item label="关联单据创建时间">
  34. <rangeDate ref="createDate" @change="createDateChange" />
  35. </a-form-item>
  36. </a-col>
  37. <a-col :md="7" :sm="24">
  38. <a-form-item label="审核时间">
  39. <rangeDate ref="rangeDate" @change="dateChange" />
  40. </a-form-item>
  41. </a-col>
  42. <a-col :md="5" :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. <div class="btn-cont">
  50. <a-button type="primary" ghost id="chooseBillModal-modal-save" @click="handleSave">批量更新</a-button>
  51. </div>
  52. <!-- 列表 -->
  53. <s-table
  54. class="sTable"
  55. ref="table"
  56. size="small"
  57. :rowKey="(record) => record.id"
  58. :row-selection="{ columnWidth: 40 }"
  59. @rowSelection="rowSelectionFun"
  60. :columns="columns"
  61. :data="loadData"
  62. :showPagination="false"
  63. :scroll="{ y: 400 }"
  64. :defaultLoadData="false"
  65. bordered>
  66. </s-table>
  67. </a-spin>
  68. </a-drawer>
  69. </template>
  70. <script>
  71. import { commonMixin } from '@/utils/mixin'
  72. import { STable, VSelect } from '@/components'
  73. import rangeDate from '@/views/common/rangeDate.vue'
  74. import { settleInfoAllList } from '@/api/settle'
  75. export default {
  76. name: 'ChooseBillModal',
  77. components: { STable, VSelect, rangeDate },
  78. mixins: [commonMixin],
  79. props: {
  80. openModal: { // 弹框显示状态
  81. type: Boolean,
  82. default: false
  83. },
  84. nowChoose: {
  85. type: Array,
  86. default: () => {
  87. return []
  88. }
  89. },
  90. settleClientSn: {
  91. type: String,
  92. default: ''
  93. },
  94. settleClientType: {
  95. type: String,
  96. default: ''
  97. }
  98. },
  99. data () {
  100. const _this = this
  101. return {
  102. spinning: false,
  103. isShow: this.openModal, // 是否打开弹框
  104. disabled: false,
  105. queryParam: {
  106. auditBeginDate: '',
  107. auditEndDate: '',
  108. bizNo: '',
  109. bizType: undefined,
  110. bizCreateBeginDate: undefined,
  111. bizCreateEndDate: undefined
  112. },
  113. allData: [],
  114. // 表头
  115. columns: [
  116. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  117. { title: '单据号', dataIndex: 'bizNo', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  118. { title: '单据类型', dataIndex: 'bizTypeDictValue', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  119. { title: '关联单据创建时间', dataIndex: 'bizCreateDate', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
  120. { title: '审核时间', dataIndex: 'auditTime', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  121. { title: '金额', dataIndex: 'totalAmount', width: '12%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  122. { title: '余额', dataIndex: 'unsettleAmount', width: '12%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  123. ],
  124. // 加载数据方法 必须为 Promise 对象
  125. loadData: parameter => {
  126. this.disabled = true
  127. this.spinning = true
  128. return settleInfoAllList(Object.assign(this.queryParam, { settleClientType: this.settleClientType, settleClientSn: this.settleClientSn, notEqZero: 1 })).then(res => {
  129. let data
  130. if (res.status == 200) {
  131. data = res.data
  132. const selectedRowKeys = []
  133. const selectedRows = []
  134. for (var i = 0; i < data.length; i++) {
  135. data[i].no = i + 1
  136. data[i].settleAmount = data[i].unsettleAmount
  137. const ind = this.nowChoose.findIndex(item => item.id == data[i].id)
  138. if (ind != -1) {
  139. selectedRowKeys.push(data[i].id)
  140. selectedRows.push(data[i])
  141. }
  142. }
  143. this.$refs.table.setTableSelected(selectedRowKeys, selectedRows) // 设置表格选中项
  144. this.disabled = false
  145. }
  146. this.spinning = false
  147. return data
  148. })
  149. },
  150. rowSelectionInfo: null
  151. }
  152. },
  153. methods: {
  154. // 表格选中项
  155. rowSelectionFun (obj) {
  156. this.rowSelectionInfo = obj || null
  157. },
  158. // 关联单据创建时间
  159. createDateChange (date) {
  160. this.queryParam.bizCreateBeginDate = date[0]
  161. this.queryParam.bizCreateEndDate = date[1]
  162. },
  163. // 时间 change
  164. dateChange (date) {
  165. this.queryParam.auditBeginDate = date[0]
  166. this.queryParam.auditEndDate = date[1]
  167. },
  168. // 确定
  169. handleSave () {
  170. this.$emit('ok', this.rowSelectionInfo && this.rowSelectionInfo.selectedRows)
  171. this.isShow = false
  172. },
  173. // 重置
  174. resetSearchForm () {
  175. this.$refs.rangeDate.resetDate()
  176. this.$refs.createDate.resetDate()
  177. this.queryParam.auditBeginDate = ''
  178. this.queryParam.auditEndDate = ''
  179. this.queryParam.bizCreateBeginDate = ''
  180. this.queryParam.bizCreateEndDate = ''
  181. this.queryParam.bizNo = ''
  182. this.queryParam.bizType = undefined
  183. this.$refs.table.refresh(true)
  184. }
  185. },
  186. watch: {
  187. // 父页面传过来的弹框状态
  188. openModal (newValue, oldValue) {
  189. this.isShow = newValue
  190. },
  191. // 重定义的弹框状态
  192. isShow (newValue, oldValue) {
  193. const _this = this
  194. if (!newValue) {
  195. _this.$emit('close')
  196. _this.$refs.table.clearSelected() // 清空表格选中项
  197. _this.resetSearchForm()
  198. } else {
  199. setTimeout(() => {
  200. _this.$refs.table.refresh(true)
  201. }, 200)
  202. }
  203. }
  204. }
  205. }
  206. </script>
  207. <style lang="less">
  208. .chooseBillModal-new-modal{
  209. .btn-cont {
  210. margin: 0 0 10px 0;
  211. text-align: left;
  212. }
  213. }
  214. </style>