list.vue 8.2 KB

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