list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <a-card size="small" :bordered="false" class="shelfSetList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="货架名称">
  10. <shelfSList v-model="queryParam.shelfSn"></shelfSList>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="关联客户">
  15. <custList ref="custList" :dealerFlag="0" @change="custChange" :isEnabled="true"></custList>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="是否设置完成">
  20. <v-select
  21. v-model="queryParam.finishFlag"
  22. ref="finishFlag"
  23. id="shelfSetList-finishFlag"
  24. code="FLAG"
  25. placeholder="请选择"
  26. allowClear></v-select>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24" style="margin-bottom: 10px">
  30. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="shelfSetList-refresh">查询</a-button>
  31. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="shelfSetList-reset">重置</a-button>
  32. </a-col>
  33. </a-row>
  34. </a-form>
  35. </div>
  36. <!-- 提示 -->
  37. <a-alert type="info" style="margin-bottom: 10px">
  38. <div slot="message">注意:只有当数字货架的“是否设置完成”为"是",系统才会自动对该货架生成补货单,修理厂才能正常下单。</div>
  39. </a-alert>
  40. <!-- 列表 -->
  41. <s-table
  42. class="sTable fixPagination"
  43. ref="table"
  44. :style="{ height: tableHeight+84.5+'px' }"
  45. size="small"
  46. :rowKey="(record) => record.id"
  47. :columns="columns"
  48. :data="loadData"
  49. :scroll="{ y: tableHeight }"
  50. :defaultLoadData="false"
  51. bordered>
  52. <!-- 货架名称 -->
  53. <template slot="shelfName" slot-scope="text, record">
  54. {{record.shelfName}}
  55. <a-badge count="已注销" :number-style="{ zoom:'80%',marginLeft:'5px', color: '#fff',background:'#999' }" v-if="record.state=='WRITE_OFF'"></a-badge>
  56. </template>
  57. <!-- 货位数量 -->
  58. <template slot="shelfPlaceNum" slot-scope="text, record">
  59. <p style="margin: 0;">
  60. <span style="color: red;">
  61. {{ record.shelfPlaceBindNum||record.shelfPlaceBindNum==0 ? record.shelfPlaceBindNum:'' }}</span> /
  62. {{ record.shelfPlaceNum }}
  63. </p>
  64. </template>
  65. <!-- 是否设置完成 -->
  66. <template slot="finishFlag" slot-scope="text, record">
  67. <a-switch
  68. checkedChildren="是"
  69. unCheckedChildren="否"
  70. v-if="record.finishFlag!=undefined&&record.state!='WRITE_OFF'&&record.state!='SUSPEND'"
  71. @change="changeStatus(record)"
  72. :checked="record.finishFlag == 1"
  73. />
  74. <span v-else :style="{ color: record.finishFlag == 1 ? '#00aa00' : '#999' }">
  75. {{ record.finishFlag == 1 ? '是' : (record.finishFlag!=undefined?'否':'--') }}
  76. </span>
  77. </template>
  78. <!-- 启用禁用 -->
  79. <template slot="enableFlag" slot-scope="text, record">
  80. <a-switch
  81. checkedChildren="启用"
  82. unCheckedChildren="停用"
  83. v-if="record.state!=undefined&&record.state!='WRITE_OFF'&&record.state!='SUSPEND'"
  84. @change="enableShelf(record)"
  85. :checked="record.state == 'ENABLE'"
  86. />
  87. <span v-else :style="{ color: record.state == 'ENABLE' ? '#00aa00' : '#999' }">
  88. {{ record.state == 'ENABLE' ? '启用' : (record.state!=undefined&&record.state!='WRITE_OFF'&&record.state!='SUSPEND'?'停用':'--') }}
  89. </span>
  90. </template>
  91. <!-- 操作 -->
  92. <template slot="action" slot-scope="text, record">
  93. <div>
  94. <a-button size="small" type="link" class="button-primary" v-if="record.state!='SUSPEND'" @click="handleSet(record)">{{record.state!='WRITE_OFF'?'设置':'查看'}}</a-button>
  95. <a-button size="small" type="link" class="button-primary" v-if="record.state!='WRITE_OFF'&&record.state!='SUSPEND'" @click="handleCancel(record)">注销</a-button>
  96. </div>
  97. </template>
  98. </s-table>
  99. </a-spin>
  100. <!-- 基础设置 -->
  101. <basic-info-modal :type="0" :openModal="openModal" :nowData="nowData" @ok="handleOk" @close="openModal=false" />
  102. </a-card>
  103. </template>
  104. <script>
  105. import { commonMixin } from '@/utils/mixin'
  106. import { STable, VSelect } from '@/components'
  107. import custList from '@/views/common/custList.vue'
  108. import shelfSList from '@/views/common/shelfList'
  109. import basicInfoModal from './basicInfoModal.vue'
  110. import { shelfList, modifFinishFlag, shelfModifState } from '@/api/shelf'
  111. export default {
  112. components: { STable, VSelect, custList, shelfSList, basicInfoModal },
  113. mixins: [commonMixin],
  114. data () {
  115. return {
  116. spinning: false,
  117. tableHeight: 0,
  118. disabled: false, // 查询、重置按钮是否可操作
  119. queryParam: {
  120. shelfSn: undefined,
  121. customerSn: undefined,
  122. finishFlag: undefined,
  123. customerEntity: {
  124. customerName: undefined
  125. }
  126. },
  127. columns: [
  128. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  129. { title: '货架名称', scopedSlots: { customRender: 'shelfName' }, width: '25%', align: 'left', ellipsis: true },
  130. { title: '关联客户', dataIndex: 'customerEntity.customerName', width: '25%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  131. { title: '货位数量', scopedSlots: { customRender: 'shelfPlaceNum' }, width: '15%', align: 'center' },
  132. { title: '是否设置完成', scopedSlots: { customRender: 'finishFlag' }, width: '10%', align: 'center' },
  133. { title: '启用状态', scopedSlots: { customRender: 'enableFlag' }, width: '10%', align: 'center' },
  134. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  135. ],
  136. // 加载数据方法 必须为 Promise 对象
  137. loadData: parameter => {
  138. this.disabled = true
  139. this.spinning = true
  140. return shelfList(Object.assign(parameter, this.queryParam)).then(res => {
  141. let data
  142. if (res.status == 200) {
  143. data = res.data
  144. const no = (data.pageNo - 1) * data.pageSize
  145. for (var i = 0; i < data.list.length; i++) {
  146. data.list[i].no = no + i + 1
  147. }
  148. this.disabled = false
  149. }
  150. this.spinning = false
  151. return data
  152. })
  153. },
  154. openModal: false,
  155. nowData: null
  156. }
  157. },
  158. methods: {
  159. // 设置/修改
  160. handleSet (row) {
  161. if (row.customerSn) {
  162. this.$router.push({ path: `/numsGoodsShelves/shelfSet/set/${row.shelfSn}` })
  163. } else {
  164. this.nowData = {
  165. shelfSn: row.shelfSn,
  166. shelfName: row.shelfName
  167. }
  168. this.openModal = true
  169. }
  170. },
  171. handleOk (data) {
  172. this.$router.push({ path: `/numsGoodsShelves/shelfSet/set/${data.shelfSn}` })
  173. },
  174. // 客户 change
  175. custChange (obj, row) {
  176. if (row) {
  177. this.queryParam.customerSn = row && row.customerSn || undefined
  178. this.queryParam.customerEntity.customerName = undefined
  179. } else {
  180. this.queryParam.customerEntity.customerName = obj || undefined
  181. this.queryParam.customerSn = undefined
  182. }
  183. },
  184. // 是否设置完成
  185. changeStatus (record) {
  186. const params = {
  187. shelfSn: record.shelfSn,
  188. finishFlag: record.finishFlag == 1 ? '0' : '1'
  189. }
  190. this.spinning = true
  191. modifFinishFlag(params).then(res => {
  192. if (res.status == 200) {
  193. this.$message.success(res.message)
  194. this.$refs.table.refresh()
  195. this.spinning = false
  196. } else {
  197. this.spinning = false
  198. }
  199. })
  200. },
  201. // 启用禁用
  202. enableShelf(record){
  203. const params = {
  204. shelfSn: record.shelfSn,
  205. state: record.state == 'ENABLE' ? 'DISABLED' : 'ENABLE'
  206. }
  207. const _this = this
  208. _this.$confirm({
  209. title: '提示',
  210. content: <div style="text-align:center;">是否{(record.state == 'ENABLE'?'停用':'启用')+record.shelfName}</div>,
  211. centered: true,
  212. closable: true,
  213. class: 'confirm-center',
  214. onOk () {
  215. _this.updateState(params)
  216. }
  217. })
  218. },
  219. // 注销
  220. handleCancel(record){
  221. const params = {
  222. shelfSn: record.shelfSn,
  223. state: 'WRITE_OFF'
  224. }
  225. const _this = this
  226. _this.$confirm({
  227. title: '',
  228. content: <div style="text-align:center;"><div style="font-size:14px;">是否注销该数字货架,</div><div>点击确定,该数字货架就不可做任何操作,用户不可登陆</div><div style="font-size:12px;color:#999;margin-top:10px;">如需要迁移该数字货架的数据,可去货架设置中导出货架信息</div></div>,
  229. centered: true,
  230. closable: true,
  231. class: 'confirm-center',
  232. onOk () {
  233. _this.updateState(params)
  234. }
  235. })
  236. },
  237. updateState(params){
  238. this.spinning = true
  239. shelfModifState(params).then(res => {
  240. if (res.status == 200) {
  241. this.$message.success(res.message)
  242. this.$refs.table.refresh()
  243. this.spinning = false
  244. } else {
  245. this.spinning = false
  246. }
  247. })
  248. },
  249. // 重置
  250. resetSearchForm () {
  251. this.queryParam.shelfSn = undefined
  252. this.queryParam.customerSn = undefined
  253. this.queryParam.customerEntity.customerName = undefined
  254. this.$refs.custList.resetForm()
  255. this.queryParam.finishFlag = undefined
  256. this.$refs.table.refresh(true)
  257. },
  258. setTableH () {
  259. const tableSearchH = this.$refs.tableSearch.offsetHeight
  260. this.tableHeight = window.innerHeight - tableSearchH - 235
  261. },
  262. pageInit () {
  263. const _this = this
  264. this.$nextTick(() => { // 页面渲染完成后的回调
  265. _this.setTableH()
  266. })
  267. }
  268. },
  269. mounted () {
  270. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  271. this.pageInit()
  272. this.resetSearchForm()
  273. }
  274. },
  275. watch: {
  276. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  277. this.setTableH()
  278. }
  279. },
  280. activated () {
  281. // 如果是新页签打开,则重置当前页面
  282. if (this.$store.state.app.isNewTab) {
  283. this.pageInit()
  284. this.resetSearchForm()
  285. }
  286. // 仅刷新列表,不重置页面
  287. if (this.$store.state.app.updateList) {
  288. this.pageInit()
  289. this.$refs.table.refresh()
  290. }
  291. }
  292. }
  293. </script>