settingsIndex.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <div class="categorySet-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <div ref="headerBar">
  5. <a-page-header :ghost="false" :backIcon="false" class="header-bar">
  6. <!-- 自定义的二级文字标题 -->
  7. <template slot="subTitle">
  8. <span class="subTitle-word text-overflow" style="max-width:300px;">用户姓名:{{ decodeURI($route.query.name) }}</span>
  9. <a-button id="purchaseNewOrderEdit-back-btn" type="link" @click="handleBack" class="button-default"> <a-icon type="rollback" /> 返回列表</a-button>
  10. </template>
  11. </a-page-header>
  12. </div>
  13. <a-card size="small" :bordered="false" class="categorySet-cont">
  14. <div :style="{ height: tableHeight+84.5+'px' }">
  15. <a-tabs default-active-key="1" @change="handleTabs">
  16. <a-tab-pane key="1" tab="设置管辖区域">
  17. <div class="areaSet-wrap">
  18. <div class="table-page-search-wrapper newTableSearchName" >
  19. <div class="areaSet-btnGroup" style="margin-bottom:20px;">
  20. <a-button type="primary" class="button-error" @click="openAreaModal" ghost>选择区域</a-button>
  21. <a-button type="primary" class="button-error" @click="openDealerModal" ghost>选择经销商</a-button>
  22. </div>
  23. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  24. <a-row :gutter="15">
  25. <a-col :md="6" :sm="24">
  26. <a-form-model-item label="所在区域/分区">
  27. <subarea id="chooseDealer-subarea" ref="subarea" @change="subareaChange"></subarea>
  28. </a-form-model-item>
  29. </a-col>
  30. <a-col :md="6" :sm="24">
  31. <a-form-item label="经销商名称">
  32. <a-input id="areaSet-dealerName" v-model.trim="queryParam.dealerName" allowClear placeholder="请输入经销商名称"/>
  33. </a-form-item>
  34. </a-col>
  35. <a-col :md="6" :sm="24">
  36. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="areaSet-refresh">查询</a-button>
  37. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="areaSet-reset">重置</a-button>
  38. </a-col>
  39. </a-row>
  40. </a-form>
  41. </div>
  42. <a-spin :spinning="spinning" tip="Loading...">
  43. <!-- 列表 -->
  44. <!-- :showPagination="false" -->
  45. <s-table
  46. class="sTable fixPagination"
  47. ref="table"
  48. size="small"
  49. :rowKey="(record) => record.id"
  50. :columns="columns"
  51. :data="loadData"
  52. :defaultLoadData="false"
  53. :style="{ height: tableHeight-100+'px' }"
  54. :scroll="{ y: tableHeight-180 }"
  55. bordered>
  56. <!-- 操作 -->
  57. <template slot="action" slot-scope="text, record">
  58. <a-button
  59. size="small"
  60. type="link"
  61. class="button-error"
  62. @click="handleDel(record)"
  63. >
  64. 删除
  65. </a-button>
  66. </template>
  67. </s-table>
  68. </a-spin>
  69. </div>
  70. </a-tab-pane>
  71. <a-tab-pane key="2" tab="设置管辖品类" force-render>
  72. <categorySet ref="setCategory"></categorySet>
  73. </a-tab-pane>
  74. </a-tabs>
  75. </div>
  76. </a-card>
  77. <!-- 选择区域 -->
  78. <chooseAreaModal
  79. ref="partQuery"
  80. :showModal="openChooseArea"
  81. :chooseData="newChooseData"
  82. @ok="handleArea"
  83. @close="openChooseArea=false">
  84. </chooseAreaModal>
  85. <!-- 选择经销商 -->
  86. <a-drawer
  87. title="选择经销商"
  88. width="80%"
  89. :zIndex="100"
  90. :visible="openChooseDealer"
  91. :get-container="false"
  92. :wrap-style="{ position: 'absolute' }"
  93. @close="openChooseDealer = false">
  94. <div class="dealerModalCon">
  95. <chooseDealer @plAdd="handleAddDealer"></chooseDealer>
  96. </div>
  97. </a-drawer>
  98. </a-spin>
  99. </div>
  100. </template>
  101. <script>
  102. import { commonMixin } from '@/utils/mixin'
  103. import { STable } from '@/components'
  104. import categorySet from './categorySet'
  105. import chooseAreaModal from './chooseAreaModal'
  106. import chooseDealer from '@/views/common/chooseDealer.vue'
  107. import { bizuserScopeQueryPage, bizuserScopeSaveList, bizuserScopeDelete } from '@/api/bizuser'
  108. import subarea from '@/views/common/subarea.js'
  109. export default {
  110. name: 'SettingsIndex',
  111. mixins: [commonMixin],
  112. components: { STable, categorySet, chooseAreaModal, chooseDealer, subarea },
  113. data () {
  114. return {
  115. openChooseArea: false,
  116. openChooseDealer: false,
  117. spinning: false,
  118. tableHeight: 0,
  119. queryParam: {
  120. hasDetail: 0,
  121. subareaSn: undefined,
  122. subareaAreaSn: undefined,
  123. dealerName: ''
  124. },
  125. newChooseData: {
  126. checked: [],
  127. halfChecked: []
  128. },
  129. columns: [
  130. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  131. { title: '添加时间', dataIndex: 'createDate', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
  132. { title: '区域', dataIndex: 'subareaName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  133. { title: '分区', dataIndex: 'subareaAreaName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  134. { title: '经销商', dataIndex: 'dealerName', width: '16%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  135. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  136. ],
  137. dataList: [],
  138. disabled: false, // 查询、重置按钮是否可操作
  139. dataSource: [],
  140. openModal: false, // 新增编辑产品品牌 弹框
  141. itemSn: '', // 当前sn
  142. nowData: null, // 当前记录数据
  143. showClassifyModal: false,
  144. showBrandModal: false,
  145. ChooseClassifyPos: null,
  146. loadData: parameter => {
  147. this.disabled = true
  148. this.spinning = true
  149. this.queryParam.userSn = this.$route.query.sn
  150. return bizuserScopeQueryPage(Object.assign(parameter, this.queryParam)).then(res => {
  151. let data
  152. if (res.status == 200) {
  153. data = res.data
  154. const no = (data.pageNo - 1) * data.pageSize
  155. this.total = data.count || 0
  156. for (var i = 0; i < data.list.length; i++) {
  157. data.list[i].no = no + i + 1
  158. }
  159. this.disabled = false
  160. }
  161. this.dataList = data.list
  162. this.spinning = false
  163. return data
  164. })
  165. }
  166. }
  167. },
  168. methods: {
  169. // 选择区域>分区
  170. handleArea (con) {
  171. const chooseData = con.checked
  172. const newData = []
  173. chooseData.forEach(item => {
  174. const obj = {}
  175. obj.userSn = this.$route.query.sn
  176. if (item.indexOf('_') != -1) { // 分区获取数据带_ 区域不带下划线
  177. obj.bizType = 'subarea_area'
  178. obj.bizSn = item.replace('_', '')
  179. newData.push(obj)
  180. } else {
  181. obj.bizType = 'subarea'
  182. obj.bizSn = item
  183. newData.push(obj)
  184. }
  185. })
  186. this.saveChooseData(newData)
  187. },
  188. // 保存所选区域或经销商
  189. saveChooseData (ajaxdata) {
  190. const _this = this
  191. bizuserScopeSaveList(ajaxdata).then(res => {
  192. if (res.status == 200) {
  193. _this.openChooseArea = false
  194. _this.openChooseDealer = false
  195. _this.resetSearchForm()
  196. }
  197. })
  198. },
  199. handleTabs (val) {
  200. if (val == 2) {
  201. this.$refs.setCategory.pageInit()
  202. }
  203. },
  204. // 所在区域分区查询
  205. subareaChange (val) {
  206. this.queryParam.subareaSn = val[0] ? val[0] : undefined
  207. this.queryParam.subareaAreaSn = val[1] ? val[1] : undefined
  208. },
  209. // 重置
  210. resetSearchForm () {
  211. this.queryParam = {
  212. subareaSn: undefined,
  213. subareaAreaSn: undefined,
  214. dealerName: ''
  215. }
  216. this.$refs.subarea.clearData()
  217. this.$refs.table.refresh(true)
  218. },
  219. openAreaModal () {
  220. this.$refs.partQuery.pageInit()
  221. const _this = this
  222. const checkedArr = []
  223. _this.dataList.forEach(item => {
  224. if (item.bizType == 'subarea_area') {
  225. item.bixSn = item.bizSn + '_'
  226. }
  227. checkedArr.push(item.bizSn)
  228. })
  229. console.log('1111', checkedArr)
  230. this.newChooseData.checked = checkedArr
  231. _this.$nextTick(() => {
  232. _this.openChooseArea = true
  233. })
  234. },
  235. openDealerModal () {
  236. this.openChooseDealer = true
  237. },
  238. // 返回
  239. handleBack () {
  240. this.$router.push({ name: 'businessOwnerSettings' })
  241. },
  242. handleAddDealer (list) { const newData = [] list.forEach(con => { const obj = {}
  243. obj.userSn = this.$route.query.sn obj.bizType = 'dealer' obj.bizSn = con newData.push(obj) }) this.saveChooseData(newData) },
  244. // 删除
  245. handleDel (row) {
  246. const _this = this
  247. this.$confirm({
  248. title: '提示',
  249. content: '删除后不可恢复,确定要进行删除吗?',
  250. centered: true,
  251. onOk () {
  252. bizuserScopeDelete({ id: row.bizUserScopeSn }).then(res => {
  253. if (res.status == 200) {
  254. _this.resetSearchForm()
  255. }
  256. })
  257. }
  258. })
  259. },
  260. pageInit () {
  261. const _this = this
  262. this.$nextTick(() => { // 页面渲染完成后的回调
  263. _this.setTableH()
  264. })
  265. this.resetSearchForm()
  266. },
  267. setTableH () {
  268. const headHeight = this.$refs.headerBar.offsetHeight
  269. this.tableHeight = window.innerHeight - headHeight - 230
  270. }
  271. },
  272. watch: {
  273. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  274. this.setTableH()
  275. }
  276. },
  277. mounted () {
  278. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  279. this.pageInit()
  280. }
  281. },
  282. activated () {
  283. // 如果是新页签打开,则重置当前页面
  284. if (this.$store.state.app.isNewTab) {
  285. this.pageInit()
  286. }
  287. // 仅刷新列表,不重置页面
  288. if (this.$store.state.app.updateList) {
  289. this.pageInit()
  290. }
  291. },
  292. beforeRouteEnter (to, from, next) {
  293. next(vm => {})
  294. }
  295. }
  296. </script>
  297. <style lang="less" scoped>
  298. .categorySet-wrap{
  299. .table-operator{
  300. text-align:right;
  301. }
  302. }
  303. </style>