list.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper newTableSearchName">
  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-model-item label="人员类型">
  10. <v-select
  11. v-model="queryParam.bizUserType"
  12. ref="printStatus"
  13. id="businessOwnerSettings-printStatus"
  14. code="BIZ_USER_TYPE"
  15. placeholder="请选择人员类型"
  16. allowClear></v-select>
  17. </a-form-model-item>
  18. </a-col>
  19. <a-col :md="6" :sm="24">
  20. <a-form-item label="人员姓名">
  21. <a-input id="businessOwnerSettings-name" v-model.trim="queryParam.userName" allowClear placeholder="请输入人员姓名"/>
  22. </a-form-item>
  23. </a-col>
  24. <a-col :md="24" :sm="24" style="margin-top: 10px;text-align:center;">
  25. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="businessOwnerSettings-refresh">查询</a-button>
  26. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="businessOwnerSettings-reset">重置</a-button>
  27. </a-col>
  28. </a-row>
  29. </a-form>
  30. </div>
  31. </a-card>
  32. <a-card size="small" :bordered="false" class="dealerZoneSearch-wrap">
  33. <a-spin :spinning="spinning" tip="Loading...">
  34. <div class="table-operator">
  35. <a-button id="businessOwnerSettings-add" type="primary" class="button-error" @click="handleAdd">+新增</a-button>
  36. </div>
  37. <!-- 列表 -->
  38. <s-table
  39. class="sTable fixPagination"
  40. ref="table"
  41. :style="{ height: tableHeight+84.5+'px' }"
  42. size="small"
  43. :rowKey="(record) => record.id"
  44. :columns="columns"
  45. :showPagination="false"
  46. :data="loadData"
  47. :scroll="{ y: tableHeight }"
  48. :defaultLoadData="false"
  49. bordered>
  50. <!-- 操作 -->
  51. <template slot="action" slot-scope="text, record">
  52. <a-button size="small" type="link" class="button-warning" v-if="record.allDealerFlag!=1&&record.allProductFlag!=1" @click="handleSetCategory(record)">设置管辖范围</a-button>
  53. <a-button size="small" type="link" class="button-info" @click="handleEdit(record)">编辑</a-button>
  54. <a-button size="small" type="link" class="button-error" @click="handleDelete(record)">删除</a-button>
  55. </template>
  56. </s-table>
  57. </a-spin>
  58. </a-card>
  59. <!-- 新增 -->
  60. <addModal :itemId="itemId" ref="addUser" :openModal="openAddModal" @close="closeModal" @ok="$refs.table.refresh(true)"></addModal>
  61. </div>
  62. </template>
  63. <script>
  64. import { commonMixin } from '@/utils/mixin'
  65. import { STable, VSelect } from '@/components'
  66. import { queryPage, bizuserDelete } from '@/api/bizuser'
  67. import addModal from './addModal'
  68. export default {
  69. name: 'BusinessOwnerSettings',
  70. mixins: [commonMixin],
  71. components: { STable, VSelect, addModal },
  72. data () {
  73. return {
  74. spinning: false,
  75. disabled: false, // 查询、重置按钮是否可操作
  76. tableHeight: 0,
  77. queryParam: {
  78. bizUserType: '',
  79. userName: undefined
  80. },
  81. columns: [
  82. { title: '创建时间', dataIndex: 'createDate', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  83. { title: '人员姓名', dataIndex: 'userName', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  84. { title: '人员类型', dataIndex: 'bizUserTypeDictValue', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  85. { title: '管辖经销商', dataIndex: 'allDealerFlagDictValue', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  86. { title: '管辖品类', dataIndex: 'allProductFlagDictValue', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  87. { title: '操作', scopedSlots: { customRender: 'action' }, width: '20%', align: 'center' }
  88. ],
  89. // 加载数据方法 必须为 Promise 对象
  90. loadData: parameter => {
  91. this.disabled = true
  92. this.spinning = true
  93. return queryPage(Object.assign(parameter, this.queryParam)).then(res => {
  94. let data
  95. data = res.data
  96. const no = (data.pageNo - 1) * data.pageSize
  97. this.total = data.count || 0
  98. for (var i = 0; i < data.list.length; i++) {
  99. data.list[i].no = no + i + 1
  100. }
  101. this.disabled = false
  102. this.spinning = false
  103. return data
  104. })
  105. },
  106. openAddModal: false, // 编辑 弹框
  107. itemId: ''
  108. }
  109. },
  110. methods: {
  111. userChange (val) {
  112. this.queryParam.userSn = val.key
  113. },
  114. handleSetCategory (row) {
  115. const obj = {
  116. name: row.userName,
  117. d_flag: row.allDealerFlag,
  118. p_flag: row.allProductFlag
  119. }
  120. const newString = JSON.stringify(obj)
  121. const newObj = encodeURI(newString)
  122. this.$router.push({ name: 'categorySet', query: { sn: row.userSn, con: newObj } })
  123. },
  124. // 新增
  125. handleAdd () {
  126. this.openAddModal = true
  127. },
  128. // 重置
  129. resetSearchForm () {
  130. this.queryParam = {
  131. bizUserType: '',
  132. userName: ''
  133. }
  134. this.$refs.table.refresh(true)
  135. },
  136. // 删除
  137. handleDelete (row) {
  138. const _this = this
  139. this.$confirm({
  140. title: '提示',
  141. content: '确定要删除吗?',
  142. centered: true,
  143. onOk () {
  144. _this.spinning = true
  145. bizuserDelete({ id: row.id }).then(res => {
  146. if (res.status == 200) {
  147. _this.$message.success(res.message)
  148. _this.$refs.table.refresh()
  149. _this.spinning = false
  150. } else {
  151. _this.spinning = false
  152. }
  153. })
  154. }
  155. })
  156. },
  157. // 编辑
  158. handleEdit (row) {
  159. this.itemId = row.id
  160. this.openAddModal = true
  161. const _this = this
  162. this.$nextTick(() => {
  163. _this.$refs.addUser.getEditInfo(row)
  164. })
  165. },
  166. // 关闭弹框
  167. closeModal () {
  168. this.itemId = ''
  169. this.openAddModal = false
  170. },
  171. pageInit () {
  172. const _this = this
  173. this.$nextTick(() => { // 页面渲染完成后的回调
  174. _this.setTableH()
  175. })
  176. this.resetSearchForm()
  177. },
  178. setTableH () {
  179. const tableSearchH = this.$refs.tableSearch.offsetHeight
  180. this.tableHeight = window.innerHeight - tableSearchH - 275
  181. }
  182. },
  183. watch: {
  184. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  185. this.setTableH()
  186. }
  187. },
  188. mounted () {
  189. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  190. this.pageInit()
  191. }
  192. },
  193. activated () {
  194. // 如果是新页签打开,则重置当前页面
  195. if (this.$store.state.app.isNewTab) {
  196. this.pageInit()
  197. }
  198. // 仅刷新列表,不重置页面
  199. if (this.$store.state.app.updateList) {
  200. this.pageInit()
  201. }
  202. },
  203. beforeRouteEnter (to, from, next) {
  204. next(vm => {})
  205. }
  206. }
  207. </script>
  208. <style lang="less">
  209. .dealerZoneSearch-wrap{
  210. height: 100%;
  211. margin-top:6px;
  212. .table-operator{
  213. text-align:right;
  214. }
  215. }
  216. </style>