list.vue 8.4 KB

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