list.vue 7.2 KB

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