list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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="goodsShelvesAdministrationList-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="goodsShelvesAdministrationList-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="goodsShelvesAdministrationList-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="goodsShelvesAdministrationList-state" code="SHELF_STATE" v-model="queryParam.state" allowClear placeholder="请选择状态"></v-select>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="结算状态">
  30. <v-select id="goodsShelvesAdministrationList-settleType" code="SHELF_SETTLE_TYPE" v-model="queryParam.settleType" allowClear placeholder="请选择状态"></v-select>
  31. </a-form-item>
  32. </a-col>
  33. </template>
  34. <a-col :md="4" :sm="24" style="margin-bottom: 10px;">
  35. <a-button type="primary" @click="$refs.table.refresh(true)" id="goodsShelvesAdministrationList-search">查询</a-button>
  36. <a-button type="" @click="reset" id="goodsShelvesAdministrationList-reset" style="margin-left: 10px;">重置</a-button>
  37. <a @click="advanced=!advanced" style="margin-left: 8px">
  38. {{ advanced ? '收起' : '展开' }}
  39. <a-icon :type="advanced ? 'up' : 'down'"/>
  40. </a>
  41. </a-col>
  42. </a-row>
  43. </a-form>
  44. </div>
  45. <div class="table-operator">
  46. <a-button type="primary" class="button-error" @click="handleEdit()" id="goodsShelvesAdministrationList-handleEdit">新增数字货架</a-button>
  47. </div>
  48. <s-table
  49. class="sTable fixPagination"
  50. ref="table"
  51. :style="{ height: tableHeight+84.5+'px', wordBreak: 'break-all' }"
  52. size="small"
  53. rowKey="id"
  54. :columns="columns"
  55. :data="loadData"
  56. :scroll="{ y: tableHeight }"
  57. :defaultLoadData="false"
  58. bordered>
  59. <template slot="state" slot-scope="text, record">
  60. <div @click="changeFlagHandle(record)" style="cursor:pointer;" id="goodsShelvesAdministrationList-changeFlagHandle">{{ record.stateDictValue }}<a-icon v-if="record.state!='CLOSE'" type="edit" title="编辑" :style="{color:' #1890FF',paddingLeft: '5px'}"/></div>
  61. </template>
  62. <template slot="action" slot-scope="text, record">
  63. <a-button size="small" type="link" class="button-info" @click="handleEdit(record)" id="goodsShelvesAdministrationList-handleEdit">编辑</a-button>
  64. <a-button size="small" type="link" class="button-info" @click="handleSet(record)" id="goodsShelvesAdministrationList-handleSet">货位设置</a-button>
  65. <a-button size="small" type="link" class="button-info" @click="handleSettlement(record)" id="goodsShelvesAdministrationList-handleSettlement">结算设置</a-button>
  66. <!-- <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'))">--</span> -->
  67. </template>
  68. </s-table>
  69. </a-spin>
  70. <!--新增/编辑数字货架 -->
  71. <addGoodsShelve :visible="showModal" @refresh="$refs.table.refresh(true)" :nowData="itemData" @close="handleUserCancel"></addGoodsShelve>
  72. <!-- 货架状态更改 -->
  73. <changeStatusModal :openStatusModal="openStatusModal" :nowData="itemData" @refresh="$refs.table.refresh()" @close="openStatusModal=false"></changeStatusModal>
  74. </a-card>
  75. </template>
  76. <script>
  77. import { STable, VSelect } from '@/components'
  78. import addGoodsShelve from './addGoodsShelve.vue'
  79. import changeStatusModal from './changeStatusModal.vue'
  80. import { getShelfList } from '@/api/shelf.js'
  81. import dealerList from '@/views/common/dealerList.vue'
  82. import storeList from '@/views/common/storeList.vue'
  83. export default {
  84. name: 'UserList',
  85. components: { STable, VSelect, addGoodsShelve, changeStatusModal, storeList, dealerList },
  86. data () {
  87. return {
  88. spinning: false,
  89. advanced: false,
  90. tableHeight: 0,
  91. // 查询参数
  92. queryParam: {
  93. dealerSn: undefined, // 配件经销商sn
  94. shelfName: '', // 货架名称
  95. settleType: '', // 结算状态
  96. storeSn: undefined, // 汽车修理厂
  97. state: undefined// 货架状态
  98. },
  99. showModal: false,
  100. itemData: null, // 编辑行数据
  101. openStatusModal: false, // 货架状态弹窗初始状态
  102. // 表头
  103. columns: [
  104. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  105. { title: '货架名称', dataIndex: 'shelfName', width: '17%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  106. { title: '配件经销商', dataIndex: 'dealerName', width: '17%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  107. { title: '汽车修理厂', dataIndex: 'storeName', width: '17%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  108. { title: '货位数量', dataIndex: 'shelfPlaceNum', width: '7%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' } },
  109. { title: '结算方式', dataIndex: 'settleTypeDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  110. { title: <div>货架状态&nbsp;<a-tooltip placement='top' title='货架状态包括:未启用、已启用、已暂停、已关闭。货架状态只能按照这个过程向前流转,不能后退'><a-icon type="question-circle" /></a-tooltip></div>, width: '7%', align: 'center', scopedSlots: { customRender: 'state' } },
  111. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  112. { title: '操作', width: '15%', align: 'left', scopedSlots: { customRender: 'action' } }
  113. ],
  114. // 加载数据方法 必须为 Promise 对象
  115. loadData: parameter => {
  116. this.spinning = true
  117. return getShelfList(Object.assign(parameter, this.queryParam)).then(res => {
  118. let data
  119. if (res.status == 200) {
  120. data = res.data
  121. const no = (data.pageNo - 1) * data.pageSize
  122. for (let i = 0; i < data.list.length; i++) {
  123. const _item = data.list[i]
  124. _item.no = no + i + 1
  125. }
  126. }
  127. this.spinning = false
  128. return data
  129. })
  130. }
  131. }
  132. },
  133. methods: {
  134. // 经销商 change
  135. dealerChange (obj) {
  136. this.queryParam.dealerSn = obj.key || undefined
  137. },
  138. // 汽车修理厂 change
  139. storeChange (obj) {
  140. this.queryParam.storeSn = obj.key || undefined
  141. },
  142. // 新增
  143. openModal () {
  144. this.itemData = null
  145. this.showModal = true
  146. },
  147. // 关闭弹框
  148. handleUserCancel () {
  149. this.showModal = false
  150. this.itemData = null
  151. },
  152. // 重置
  153. reset () {
  154. this.queryParam = {
  155. dealerSn: undefined, // 配件经销商sn
  156. shelfName: '', // 货架名称
  157. settleType: '', // 结算状态
  158. storeSn: undefined, // 汽车修理厂
  159. state: undefined// 货架状态
  160. }
  161. this.$refs.dealerList.resetForm()
  162. this.$refs.storeList.resetForm()
  163. this.$refs.table.refresh(true)
  164. },
  165. // 编辑
  166. handleEdit (row) {
  167. console.log(row, 'row')
  168. this.showModal = true
  169. if (row) { // 编辑
  170. this.itemData = row
  171. } else {
  172. this.itemData = null
  173. }
  174. },
  175. // 货位设置
  176. handleSet (row) {
  177. this.$router.push({ name: 'goodsAllocationSet', params: { shelfSn: row.shelfSn } })
  178. },
  179. // 结算设置
  180. handleSettlement (row) {
  181. this.$router.push({ name: 'settlementSet', params: { shelfSn: row.shelfSn } })
  182. },
  183. // 修改状态
  184. changeFlagHandle (row) {
  185. this.itemData = row
  186. if (row.state != 'CLOSE') {
  187. this.openStatusModal = true
  188. }
  189. },
  190. pageInit () {
  191. const _this = this
  192. _this.$refs.table.refresh()
  193. this.$nextTick(() => { // 页面渲染完成后的回调
  194. _this.setTableH()
  195. })
  196. },
  197. setTableH () {
  198. const tableSearchH = this.$refs.tableSearch.offsetHeight
  199. this.tableHeight = window.innerHeight - tableSearchH - 215
  200. }
  201. },
  202. watch: {
  203. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  204. this.setTableH()
  205. }
  206. },
  207. mounted () {
  208. this.pageInit()
  209. this.reset()
  210. // if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  211. // this.pageInit()
  212. // this.reset()
  213. // }
  214. },
  215. beforeRouteEnter (to, from, next) {
  216. next(vm => {
  217. if (from.name == 'goodsAllocationSet' || from.name == 'settlementSet') {
  218. vm.$refs.table.refresh()
  219. } else {
  220. vm.reset()
  221. }
  222. })
  223. // next(vm => {
  224. // vm.$refs.table.refresh()
  225. // })
  226. }
  227. // activated () {
  228. // // 如果是新页签打开,则重置当前页面
  229. // if (this.$store.state.app.isNewTab) {
  230. // this.pageInit()
  231. // this.resetSearchForm()
  232. // }
  233. // // 仅刷新列表,不重置页面
  234. // if (this.$store.state.app.updateList) {
  235. // this.pageInit()
  236. // this.$refs.table.refresh()
  237. // }
  238. // }
  239. }
  240. </script>