list.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="provincialWarehouse-wrap searchBoxNormal">
  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. <a-input id="provincialWarehouse-name" v-model.trim="queryParam.serviceCenterName" allowClear placeholder="请输入省仓名称"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="省仓客户">
  15. <a-input id="provincialWarehouse-dealerName" v-model.trim="queryParam.dealerName" allowClear placeholder="请输入省仓客户"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="省仓状态">
  20. <v-select code="ENABLE_FLAG" id="provincialWarehouse-enableFlag" v-model="queryParam.enableFlag" allowClear placeholder="请选择省仓状态"></v-select>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24">
  24. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="provincialWarehouse-refresh">查询</a-button>
  25. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="provincialWarehouse-reset">重置</a-button>
  26. </a-col>
  27. </a-row>
  28. </a-form>
  29. </div>
  30. </a-card>
  31. <a-card size="small" :bordered="false">
  32. <a-spin :spinning="spinning" tip="Loading...">
  33. <!-- 操作按钮 -->
  34. <div class="table-operator">
  35. <a-button id="provincialWarehouse-add" type="primary" v-if="$hasPermissions('B_dealerAccount_add')" @click="handleEdit()">新增</a-button>
  36. </div>
  37. <!-- 列表 -->
  38. <s-table
  39. class="sTable fixPagination"
  40. ref="table"
  41. :style="{ height: tableHeight+70+'px' }"
  42. size="small"
  43. :rowKey="(record) => record.id"
  44. :columns="columns"
  45. :data="loadData"
  46. :pageSize="30"
  47. :scroll="{ y: tableHeight }"
  48. :defaultLoadData="false"
  49. bordered>
  50. <!-- 省仓客户 -->
  51. <template slot="customNum" slot-scope="text, record">
  52. {{ !queryParam.dealerName?'共':'' }}有<span style="font-weight:bold;font-size:13px;vertical-align:top;">{{ record.customerNum }}</span>个客户
  53. </template>
  54. <!-- 省仓状态 -->
  55. <template slot="loginFlag" slot-scope="text, record">
  56. <a-switch
  57. id="provincialWarehouse-enableFlag"
  58. v-if="$hasPermissions('B_dealerAccount_enable')"
  59. checkedChildren="启用"
  60. unCheckedChildren="禁用"
  61. @change="openStatusModal(record)"
  62. :checked="record.enableFlag == 1 ? true : false" />
  63. <span v-else :style="{color:(record.enableFlag==1?'#00aa00':'#999')}"> {{ record.enableFlag==1? '已启用': '已禁用' }} </span>
  64. </template>
  65. <!-- 操作 -->
  66. <template slot="action" slot-scope="text, record">
  67. <a-button
  68. size="small"
  69. type="link"
  70. v-if="$hasPermissions('B_dealerAccount_edit')"
  71. class="button-info"
  72. @click="handleDealer(record)"
  73. id="provincialWarehouse-edit-btn">关联经销商</a-button>
  74. <span v-else>--</span>
  75. </template>
  76. </s-table>
  77. </a-spin>
  78. <!-- 新增/编辑 -->
  79. <provincial-warehouse-add-modal v-drag :openModal="openModal" @ok="$refs.table.refresh(true)" @close="closeModal" />
  80. </a-card>
  81. </div>
  82. </template>
  83. <script>
  84. import { commonMixin } from '@/utils/mixin'
  85. import { STable, VSelect } from '@/components'
  86. import provincialWarehouseAddModal from './addModal.vue'
  87. import { serviceCenterList, provincialWarehouseEnable, serviceCenterBinding } from '@/api/serviceCenter'
  88. export default {
  89. name: 'DealerAccountManagementList',
  90. mixins: [commonMixin],
  91. components: { STable, VSelect, provincialWarehouseAddModal },
  92. data () {
  93. return {
  94. spinning: false,
  95. tableHeight: 0,
  96. queryParam: { // 查询条件
  97. serviceCenterName: '',
  98. dealerName: '',
  99. enableFlag: undefined
  100. },
  101. disabled: false, // 查询、重置按钮是否可操作
  102. columns: [
  103. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  104. { title: '创建时间', dataIndex: 'createDate', width: '10%', align: 'center' },
  105. { title: '区域', dataIndex: 'subareaName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  106. { title: '分区', dataIndex: 'subareaAreaName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  107. { title: '省仓名称', dataIndex: 'serviceCenterName', width: '18%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  108. { title: '经销商名称', dataIndex: 'dealerName', width: '18%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  109. { title: '省仓客户', dataIndex: 'customerNum', width: '11%', align: 'center', scopedSlots: { customRender: 'customNum' } },
  110. { title: '省仓状态', scopedSlots: { customRender: 'loginFlag' }, width: '9%', align: 'center' },
  111. { title: '操作', scopedSlots: { customRender: 'action' }, width: '11%', align: 'center' }
  112. ],
  113. // 加载数据方法 必须为 Promise 对象
  114. loadData: parameter => {
  115. this.disabled = true
  116. this.spinning = true
  117. return serviceCenterList(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 (var i = 0; i < data.list.length; i++) {
  123. data.list[i].no = no + i + 1
  124. data.list[i].loginFlag = Number(data.list[i].loginFlag)
  125. }
  126. this.disabled = false
  127. }
  128. this.spinning = false
  129. return data
  130. })
  131. },
  132. openModal: false // 新增编辑 弹框
  133. }
  134. },
  135. methods: {
  136. // 关联经销商
  137. handleDealer (row) {
  138. this.$router.push({ name: 'relatedDealersList', params: { sn: row.serviceCenterSn, name: row.serviceCenterName } })
  139. },
  140. // 重置
  141. resetSearchForm () {
  142. this.queryParam.serviceCenterName = ''
  143. this.queryParam.dealerName = ''
  144. this.queryParam.enableFlag = undefined
  145. this.notDealerSn = null
  146. this.$refs.table.refresh(true)
  147. },
  148. // 新增/编辑
  149. handleEdit (row) {
  150. this.openModal = true
  151. },
  152. // 关闭弹框
  153. closeModal () {
  154. this.openModal = false
  155. },
  156. // 打开启用 禁用 弹窗
  157. openStatusModal (record) {
  158. const _this = this
  159. if (record.enableFlag == 1) {
  160. this.$confirm({
  161. title: '提示',
  162. content: '禁用省仓后,省仓客户无法向省仓采购,确定禁用省仓吗?',
  163. centered: true,
  164. onOk () {
  165. const ajaxData = {
  166. serviceCenterSn: record.serviceCenterSn,
  167. enableFlag: '0'
  168. }
  169. _this.changeStatus(ajaxData)
  170. }
  171. })
  172. } else {
  173. const params = {
  174. serviceCenterSn: record.serviceCenterSn,
  175. enableFlag: '1'
  176. }
  177. _this.changeStatus(params)
  178. }
  179. },
  180. // 启用 禁用
  181. changeStatus (params) {
  182. this.spinning = true
  183. provincialWarehouseEnable(params).then(res => {
  184. if (res.status == 200) {
  185. this.$message.success(res.message)
  186. }
  187. this.spinning = false
  188. this.$refs.table.refresh()
  189. })
  190. },
  191. pageInit () {
  192. const _this = this
  193. this.$nextTick(() => { // 页面渲染完成后的回调
  194. _this.setTableH()
  195. })
  196. },
  197. setTableH () {
  198. const tableSearchH = this.$refs.tableSearch.offsetHeight
  199. this.tableHeight = window.innerHeight - tableSearchH - 240
  200. }
  201. },
  202. watch: {
  203. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  204. this.setTableH()
  205. }
  206. },
  207. mounted () {
  208. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  209. this.pageInit()
  210. this.resetSearchForm()
  211. }
  212. },
  213. activated () {
  214. // 如果是新页签打开,则重置当前页面
  215. if (this.$store.state.app.isNewTab) {
  216. this.pageInit()
  217. this.resetSearchForm()
  218. }
  219. // 仅刷新列表,不重置页面
  220. if (this.$store.state.app.updateList) {
  221. this.$refs.table.refresh()
  222. this.pageInit()
  223. }
  224. }
  225. }
  226. </script>