list.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <a-card size="small" :bordered="false">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <div ref="tableSearch" class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="货架名称">
  9. <a-input id="bondManagementList-shelfName" allowClear v-model.trim="queryParam.shelfName" placeholder="请输入货架名称"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="配件经销商">
  14. <dealerList ref="dealerList" @change="dealerChange" id="bondManagementList-dealerChange"></dealerList>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="汽车修理厂">
  19. <storeList ref="storeList" @change="storeChange" id="bondManagementList-storeChange"></storeList>
  20. </a-form-item>
  21. </a-col>
  22. <template v-if="advanced">
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="状态">
  25. <v-select id="bondManagementList-state" code="BOND_RECORD_STATE" v-model="queryParam.state" allowClear placeholder="请选择状态"></v-select>
  26. </a-form-item>
  27. </a-col>
  28. </template>
  29. <a-col :md="4" :sm="24" style="margin-bottom: 10px;">
  30. <a-button type="primary" @click="$refs.table.refresh(true)" id="bondManagementList-refresh">查询</a-button>
  31. <a-button type="" @click="reset" style="margin-left: 10px;" id="bondManagementList-reset">重置</a-button>
  32. <a @click="advanced=!advanced" style="margin-left: 8px">
  33. {{ advanced ? '收起' : '展开' }}
  34. <a-icon :type="advanced ? 'up' : 'down'"/>
  35. </a>
  36. </a-col>
  37. </a-row>
  38. </a-form>
  39. </div>
  40. <div class="table-operator">
  41. <a-button size="small" type="primary" class="button-error" @click="handleEdit()" id="bondManagementList-handleEdit">新增保证金</a-button>
  42. </div>
  43. <s-table
  44. class="sTable fixPagination"
  45. ref="table"
  46. :style="{ height: tableHeight+84.5+'px', wordBreak: 'break-all' }"
  47. size="small"
  48. rowKey="id"
  49. :columns="columns"
  50. :data="loadData"
  51. :scroll="{ y: tableHeight }"
  52. :defaultLoadData="false"
  53. bordered>
  54. <template slot="action" slot-scope="text, record" >
  55. <a-button
  56. size="small"
  57. type="link"
  58. class="button-info"
  59. @click="handleEdit(record)"
  60. v-if="record.state=='WAIT'"
  61. id="bondManagementList-handleEdit">编辑</a-button>
  62. <a-button
  63. size="small"
  64. type="link"
  65. class="button-info"
  66. @click="handleDel(record)"
  67. v-if="record.state=='WAIT'"
  68. id="bondManagementList-handleDel">删除</a-button>
  69. <span style="display:inline-block;padding-left:7px" v-if="record.state=='FINISH'">--</span>
  70. <!-- <span v-if="!($hasPermissions('B_powerMD_user_edit') && record.superAdmin!=1) && !(record.loginFlag==1 && record.ownerOrgFlag==1 && $hasPermissions('B_powerMD_user_restPwd')) && !(record.loginFlag==0 && record.ownerOrgFlag==1 && $hasPermissions('B_powerMD_user_del'))" style="display:inline-block;padding-left:7px">--</span> -->
  71. </template>
  72. </s-table>
  73. </a-spin>
  74. <!--新增/编辑数字货架 -->
  75. <addbond :visible="showModal" @refresh="$refs.table.refresh(true)" :nowData="itemData" @close="handleUserCancel"></addbond>
  76. </a-card>
  77. </template>
  78. <script>
  79. import { STable, VSelect } from '@/components'
  80. import addbond from './addbond.vue'
  81. import { bondRecordByPage, bondRecordDel } from '@/api/boundRecord.js'
  82. import dealerList from '@/views/common/dealerList.vue'
  83. import storeList from '@/views/common/storeList.vue'
  84. import { toThousands } from '@/libs/tools.js'
  85. export default {
  86. name: 'UserList',
  87. components: { STable, VSelect, dealerList, storeList, addbond },
  88. data () {
  89. return {
  90. spinning: false,
  91. advanced: false,
  92. tableHeight: 0,
  93. // 查询参数
  94. queryParam: {
  95. shelfName: '',
  96. state: undefined
  97. },
  98. showModal: false,
  99. itemData: null, // 编辑行数据
  100. openStatusModal: false, // 货架状态弹窗初始状态
  101. // 表头
  102. columns: [
  103. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  104. { title: '货架名称', dataIndex: 'shelfName', width: '15%', align: 'left', customRender: function (text) { return text || '--' } },
  105. { title: '配件经销商', dataIndex: 'dealerName', width: '15%', align: 'left', customRender: function (text) { return text || '--' } },
  106. { title: '汽车修理厂', dataIndex: 'storeName', width: '15%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  107. { title: '保证金金额', dataIndex: 'bondAmount', width: '10%', align: 'right', customRender: function (text) { return toThousands(text, 2) || '--' } },
  108. { title: '状态', dataIndex: 'stateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  109. { title: '创建时间', dataIndex: 'createDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  110. { title: '操作', width: '10%', align: 'left', scopedSlots: { customRender: 'action' } }
  111. ],
  112. // 加载数据方法 必须为 Promise 对象
  113. loadData: parameter => {
  114. this.spinning = true
  115. return bondRecordByPage(Object.assign(parameter, this.queryParam)).then(res => {
  116. let data
  117. if (res.status == 200) {
  118. data = res.data
  119. const no = (data.pageNo - 1) * data.pageSize
  120. for (let i = 0; i < data.list.length; i++) {
  121. const _item = data.list[i]
  122. _item.no = no + i + 1
  123. }
  124. }
  125. this.spinning = false
  126. return data
  127. })
  128. }
  129. }
  130. },
  131. methods: {
  132. // 经销商 change
  133. dealerChange (obj) {
  134. this.queryParam.dealerSn = obj.key || undefined
  135. },
  136. // 汽车修理厂 change
  137. storeChange (obj) {
  138. this.queryParam.storeSn = obj.key || undefined
  139. },
  140. // 新增/编辑
  141. handleEdit (row) {
  142. if (row) {
  143. this.itemData = row
  144. } else {
  145. this.itemData = null
  146. }
  147. this.showModal = true
  148. },
  149. // 关闭弹框
  150. handleUserCancel () {
  151. this.showModal = false
  152. this.itemData = null
  153. },
  154. // 重置
  155. reset () {
  156. this.queryParam = {
  157. shelfName: '',
  158. state: undefined
  159. }
  160. this.$refs.dealerList.resetForm()
  161. this.$refs.storeList.resetForm()
  162. this.$refs.table.refresh(true)
  163. },
  164. // 删除
  165. handleDel (row) {
  166. const _this = this
  167. this.$confirm({
  168. title: '警告',
  169. content: '删除后无法恢复,确认删除?',
  170. centered: true,
  171. onOk () {
  172. _this.spinning = true
  173. bondRecordDel({
  174. bondRecordSn: row.bondRecordSn
  175. }).then(res => {
  176. if (res.status == 200) {
  177. _this.$message.success(res.message)
  178. _this.$refs.table.refresh()
  179. _this.spinning = false
  180. } else {
  181. _this.spinning = false
  182. }
  183. })
  184. }
  185. })
  186. },
  187. pageInit () {
  188. const _this = this
  189. this.$nextTick(() => { // 页面渲染完成后的回调
  190. _this.setTableH()
  191. })
  192. },
  193. setTableH () {
  194. const tableSearchH = this.$refs.tableSearch.offsetHeight
  195. this.tableHeight = window.innerHeight - tableSearchH - 215
  196. }
  197. },
  198. watch: {
  199. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  200. this.setTableH()
  201. }
  202. },
  203. mounted () {
  204. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  205. this.pageInit()
  206. this.reset()
  207. }
  208. },
  209. activated () {
  210. // 如果是新页签打开,则重置当前页面
  211. if (this.$store.state.app.isNewTab) {
  212. this.pageInit()
  213. this.reset()
  214. }
  215. }
  216. }
  217. </script>
  218. <style lang="less">
  219. </style>