settingsIndex.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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;">用户姓名:测试测试</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">
  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="areaSet-subareaSn" ref="subarea" v-model="queryParam.subareaSn" @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. <s-table
  45. class="sTable fixPagination"
  46. ref="table"
  47. size="small"
  48. :rowKey="(record) => record.id"
  49. :columns="columns"
  50. :showPagination="false"
  51. :data="loadData"
  52. :defaultLoadData="false"
  53. bordered>
  54. </s-table>
  55. </a-spin>
  56. <!-- :style="{ height: tableHeight+'px' }"
  57. :scroll="{ y: tableHeight }" -->
  58. </div>
  59. </a-tab-pane>
  60. <a-tab-pane key="2" tab="设置管辖品类" force-render>
  61. <categorySet></categorySet>
  62. </a-tab-pane>
  63. </a-tabs>
  64. </div>
  65. </a-card>
  66. <!-- 选择区域 -->
  67. <chooseAreaModal
  68. ref="partQuery"
  69. :showModal="openChooseArea"
  70. @close="openChooseArea=false">
  71. </chooseAreaModal>
  72. <!-- 选择经销商 -->
  73. <a-drawer
  74. title="选择经销商"
  75. width="80%"
  76. :zIndex="100"
  77. :visible="openChooseDealer"
  78. :get-container="false"
  79. :wrap-style="{ position: 'absolute' }"
  80. @close="openChooseDealer = false">
  81. <div class="dealerModalCon">
  82. <chooseDealer></chooseDealer>
  83. </div>
  84. </a-drawer>
  85. </a-spin>
  86. </div>
  87. </template>
  88. <script>
  89. import { commonMixin } from '@/utils/mixin'
  90. import { STable } from '@/components'
  91. import categorySet from './categorySet'
  92. import chooseAreaModal from './chooseAreaModal'
  93. import chooseDealer from '@/views/common/chooseDealer.vue'
  94. export default {
  95. name: 'SettingsIndex',
  96. mixins: [commonMixin],
  97. components: { STable, categorySet, chooseAreaModal, chooseDealer },
  98. data () {
  99. return {
  100. openChooseArea: false,
  101. openChooseDealer: false,
  102. spinning: false,
  103. tableHeight: 0,
  104. queryParam: {
  105. subareaSn: undefined,
  106. subareaAreaSn: undefined,
  107. dealerName: ''
  108. },
  109. columns: [
  110. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  111. { title: '添加时间', dataIndex: 'subareaName1', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
  112. { title: '区域', dataIndex: 'subareaName2', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  113. { title: '分区', dataIndex: 'subareaName3', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  114. { title: '经销商', dataIndex: 'subareaName4', width: '16%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  115. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  116. ],
  117. disabled: false, // 查询、重置按钮是否可操作
  118. dataSource: [],
  119. openModal: false, // 新增编辑产品品牌 弹框
  120. itemSn: '', // 当前sn
  121. nowData: null, // 当前记录数据
  122. showClassifyModal: false,
  123. showBrandModal: false,
  124. ChooseClassifyPos: null,
  125. loadData: parameter => {
  126. this.disabled = true
  127. this.spinning = true
  128. return subareaQueryIncludeAreaAll(Object.assign(parameter,this.queryParam)).then(res => {
  129. let data
  130. if (res.status == 200) {
  131. data = res.data
  132. const no = 0
  133. for (var i = 0; i < data.length; i++) {
  134. data[i].no = no + i + 1
  135. }
  136. this.disabled = false
  137. }
  138. this.spinning = false
  139. return data
  140. })
  141. }
  142. }
  143. },
  144. methods: {
  145. subareaChange(val){
  146. this.queryParam.subareaSn = val[0] ? val[0] : undefined
  147. this.queryParam.subareaAreaSn = val[1] ? val[1] : undefined
  148. },
  149. resetSearchForm () {
  150. this.queryParam = {
  151. subareaSn: undefined,
  152. subareaAreaSn: undefined,
  153. dealerName: ''
  154. }
  155. this.$refs.subarea.clearData()
  156. this.$refs.table.refresh(true)
  157. },
  158. openAreaModal () {
  159. this.openChooseArea = true
  160. },
  161. openDealerModal () {
  162. this.openChooseDealer = true
  163. },
  164. // 返回
  165. handleBack () {
  166. this.$router.push({ name: 'businessOwnerSettings' })
  167. },
  168. // 新增管辖品类
  169. addCategory () {
  170. const newData = {
  171. classifyList: [],
  172. brandList: []
  173. }
  174. this.dataSource.push(newData)
  175. },
  176. // 删除分类、品牌标签
  177. delLabel (pos, i, name) {
  178. this.dataSource[pos][name].splice(i, 1)
  179. },
  180. // 添加分类标签
  181. addClassifyTag (pos, row) {
  182. this.ChooseClassifyPos = pos
  183. this.showClassifyModal = true
  184. },
  185. handleClassifyModal (con) {
  186. const chooseList = con
  187. this.showClassifyModal = false
  188. this.dataSource[this.ChooseClassifyPos].classifyList = [...this.dataSource[this.ChooseClassifyPos].classifyList, ...chooseList]
  189. },
  190. // 添加品牌标签
  191. addBrandTag (pos, row) {
  192. this.ChooseBrandPos = pos
  193. this.showBrandModal = true
  194. },
  195. // 保存
  196. save () {
  197. },
  198. // 新增/编辑
  199. handleEdit (row) {
  200. if (row) {
  201. this.itemSn = row.warehouseLocationSn
  202. row.warehouseSn = this.$route.params.sn
  203. this.nowData = row
  204. } else {
  205. this.itemSn = null
  206. this.nowData = { warehouseSn: this.$route.params.sn }
  207. }
  208. this.openModal = true
  209. },
  210. // 新增/编辑 成功
  211. handleOk () {
  212. this.$refs.table.refresh(true)
  213. },
  214. // 关闭弹框
  215. closeModal () {
  216. this.itemSn = ''
  217. this.openModal = false
  218. },
  219. // 删除
  220. handleDel (pos) {
  221. const _this = this
  222. this.$confirm({
  223. title: '提示',
  224. content: '删除后不可恢复,确定要进行删除吗?',
  225. centered: true,
  226. onOk () {
  227. _this.dataSource.splice(pos, 1)
  228. }
  229. })
  230. },
  231. pageInit () {
  232. const _this = this
  233. this.$nextTick(() => { // 页面渲染完成后的回调
  234. _this.setTableH()
  235. })
  236. },
  237. setTableH () {
  238. const headHeight = this.$refs.headerBar.offsetHeight
  239. this.tableHeight = window.innerHeight - headHeight - 230
  240. }
  241. },
  242. watch: {
  243. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  244. this.setTableH()
  245. }
  246. },
  247. mounted () {
  248. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  249. this.pageInit()
  250. }
  251. },
  252. activated () {
  253. // 如果是新页签打开,则重置当前页面
  254. if (this.$store.state.app.isNewTab) {
  255. this.pageInit()
  256. }
  257. // 仅刷新列表,不重置页面
  258. if (this.$store.state.app.updateList) {
  259. this.pageInit()
  260. this.$refs.table.refresh()
  261. }
  262. },
  263. beforeRouteEnter (to, from, next) {
  264. next(vm => {})
  265. }
  266. }
  267. </script>
  268. <style lang="less" scoped>
  269. .categorySet-wrap{
  270. .table-operator{
  271. text-align:right;
  272. }
  273. }
  274. </style>