list.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper newTableSearchName">
  6. <a-form layout="inline" id="businessOwnerSettings-form" @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. <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-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="6" :sm="24">
  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. <!-- 操作按钮 -->
  33. <a-card size="small" :bordered="false" class="dealerZoneSearch-wrap">
  34. <a-spin :spinning="spinning" tip="Loading...">
  35. <div class="table-operator">
  36. <a-button id="businessOwnerSettings-add" type="primary" @click="handleAdd">新增</a-button>
  37. </div>
  38. <!-- 列表 -->
  39. <s-table
  40. class="sTable fixPagination"
  41. ref="table"
  42. :style="{ height: tableHeight+70+'px' }"
  43. size="small"
  44. :rowKey="(record) => record.id"
  45. :columns="columns"
  46. :data="loadData"
  47. :pageSize="30"
  48. :scroll="{ y: tableHeight }"
  49. :defaultLoadData="false"
  50. bordered>
  51. <template slot="showWarehouse" slot-scope="text, record">
  52. <div v-if="record.warehouseList&&record.warehouseList.length>0 ">
  53. <a-tooltip placement="bottom" class="warehouseBox">
  54. <template slot="title">
  55. <span v-for="con in record.warehouseList" :key="con.id">
  56. {{ con.name }}
  57. </span>
  58. </template>
  59. <span v-for="con in record.warehouseList" :key="con.id">
  60. {{ con.name }}
  61. </span>
  62. </a-tooltip>
  63. </div>
  64. <div v-else>--</div>
  65. </template>
  66. <!-- 操作 -->
  67. <template slot="action" slot-scope="text, record">
  68. <a-button
  69. size="small"
  70. type="link"
  71. :id="'businessOwnerSettings-set-btn'+record.id"
  72. class="button-warning"
  73. v-if="record.allDealerFlag!=1 || record.allProductFlag!=1 ||record.allSupplierFlag&&record.allSupplierFlag!=1"
  74. @click="handleSetCategory(record)">设置管辖范围</a-button>
  75. <a-button size="small" type="link" :id="'businessOwnerSettings-edit-btn'+record.id" class="button-info" @click="handleEdit(record)">编辑</a-button>
  76. <a-button size="small" type="link" :id="'businessOwnerSettings-del-btn'+record.id" class="button-error" @click="handleDelete(record)">删除</a-button>
  77. </template>
  78. </s-table>
  79. </a-spin>
  80. </a-card>
  81. <!-- 新增 -->
  82. <addModal :itemId="itemId" ref="addUser" :openModal="openAddModal" @close="closeModal" @ok="$refs.table.refresh(true)"></addModal>
  83. </div>
  84. </template>
  85. <script>
  86. import { commonMixin } from '@/utils/mixin'
  87. // 组件
  88. import { STable, VSelect } from '@/components'
  89. import addModal from './addModal'
  90. // 接口
  91. import { queryPage, bizuserDelete } from '@/api/bizuser'
  92. export default {
  93. name: 'BusinessOwnerSettings',
  94. mixins: [commonMixin],
  95. components: { STable, VSelect, addModal },
  96. data () {
  97. return {
  98. spinning: false,
  99. disabled: false, // 查询、重置按钮是否可操作
  100. tableHeight: 0, // 表格高度
  101. // 查询参数
  102. queryParam: {
  103. bizUserType: '', // 人员类型
  104. userName: undefined// 人员姓名
  105. },
  106. columns: [
  107. { title: '创建时间', dataIndex: 'createDate', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  108. { title: '人员姓名', dataIndex: 'userName', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  109. { title: '人员类型', dataIndex: 'bizUserTypeDictValue', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  110. { title: '管辖经销商', dataIndex: 'allDealerFlagDictValue', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  111. { title: '管辖品类', dataIndex: 'allProductFlagDictValue', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  112. { title: '管辖供应商', dataIndex: 'allSupplierFlagDictValue', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  113. { title: '管辖仓库', scopedSlots: { customRender: 'showWarehouse' }, width: '22%', align: 'center' },
  114. { title: '操作', scopedSlots: { customRender: 'action' }, width: '20%', align: 'center' }
  115. ],
  116. // 加载数据方法 必须为 Promise 对象
  117. loadData: parameter => {
  118. this.disabled = true
  119. this.spinning = true
  120. // 获取列表数据 有分页
  121. return queryPage(Object.assign(parameter, this.queryParam)).then(res => {
  122. let data
  123. data = res.data
  124. // 计算列表序号
  125. const no = (data.pageNo - 1) * data.pageSize
  126. this.total = data.count || 0
  127. for (var i = 0; i < data.list.length; i++) {
  128. data.list[i].no = no + i + 1
  129. }
  130. this.disabled = false
  131. this.spinning = false
  132. return data
  133. })
  134. },
  135. openAddModal: false, // 编辑 弹框
  136. itemId: ''// 当前id
  137. }
  138. },
  139. methods: {
  140. // 设置管辖范围
  141. handleSetCategory (row) {
  142. this.$router.push({ name: 'categorySet', query: { sn: row.userSn, id: row.id } })
  143. },
  144. // 新增
  145. handleAdd () {
  146. this.itemId = ''
  147. this.openAddModal = true
  148. },
  149. // 重置
  150. resetSearchForm () {
  151. this.queryParam = {
  152. bizUserType: '',
  153. userName: ''
  154. }
  155. this.itemId = ''
  156. this.$refs.table.refresh(true)
  157. },
  158. // 删除
  159. handleDelete (row) {
  160. const _this = this
  161. this.$confirm({
  162. title: '提示',
  163. content: '确定要删除吗?',
  164. centered: true,
  165. onOk () {
  166. _this.spinning = true
  167. bizuserDelete({ id: row.id }).then(res => {
  168. if (res.status == 200) {
  169. _this.$message.success(res.message)
  170. _this.$refs.table.refresh()
  171. _this.spinning = false
  172. } else {
  173. _this.spinning = false
  174. }
  175. })
  176. }
  177. })
  178. },
  179. // 编辑
  180. handleEdit (row) {
  181. this.itemId = row.id
  182. this.openAddModal = true
  183. const _this = this
  184. this.$nextTick(() => {
  185. _this.$refs.addUser.getEditInfo(row)
  186. })
  187. },
  188. // 关闭弹框
  189. closeModal () {
  190. this.itemId = ''
  191. this.openAddModal = false
  192. },
  193. // 初始化
  194. pageInit () {
  195. const _this = this
  196. this.$nextTick(() => { // 页面渲染完成后的回调
  197. _this.setTableH()
  198. })
  199. this.resetSearchForm()
  200. },
  201. // 计算表格高度
  202. setTableH () {
  203. const tableSearchH = this.$refs.tableSearch.offsetHeight
  204. this.tableHeight = window.innerHeight - tableSearchH - 240
  205. }
  206. },
  207. watch: {
  208. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  209. this.setTableH()
  210. }
  211. },
  212. mounted () {
  213. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  214. this.pageInit()
  215. }
  216. },
  217. activated () {
  218. // 如果是新页签打开,则重置当前页面
  219. if (this.$store.state.app.isNewTab) {
  220. this.pageInit()
  221. }
  222. // 仅刷新列表,不重置页面
  223. if (this.$store.state.app.updateList) {
  224. this.pageInit()
  225. }
  226. },
  227. beforeRouteEnter (to, from, next) {
  228. next(vm => {})
  229. }
  230. }
  231. </script>
  232. <style lang="less">
  233. .dealerZoneSearch-wrap{
  234. height: 100%;
  235. margin-top:6px;
  236. .warehouseBox{
  237. width: 100%;
  238. display: -webkit-box;
  239. -webkit-box-orient: vertical;
  240. -webkit-line-clamp: 2;
  241. overflow: hidden;
  242. text-overflow: ellipsis;
  243. }
  244. .warehouseBox span::after{
  245. content:','
  246. }
  247. .warehouseBox span:last-child::after{
  248. content:''
  249. }
  250. }
  251. </style>