permissionSettingNew.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <div class="permissionSetting-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" @back="handleBack" class="permissionSetting-cont">
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="permissionSetting-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <span style="margin-left: 20px;color: #666;">经销商:{{ $route.params.name }}</span>
  9. </template>
  10. </a-page-header>
  11. <a-card size="small" :bordered="false" class="permissionSetting-main">
  12. <!-- 搜索条件 -->
  13. <div ref="tableSearch" class="table-page-search-wrapper">
  14. <a-form-model
  15. id="permissionSetting-form"
  16. ref="ruleForm"
  17. class="form-model-con"
  18. layout="inline"
  19. :model="queryParam">
  20. <a-row :gutter="15">
  21. <a-col :md="6" :sm="24">
  22. <a-form-model-item label="品牌" prop="productBrandSn">
  23. <ProductBrand id="permissionSetting-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :md="6" :sm="24">
  27. <a-form-model-item label="产品分类" prop="productType">
  28. <productTypeAll placeholder="请选择产品分类" @change="changeProductType" v-model="productType" id="permissionSetting-productType"></productTypeAll>
  29. </a-form-model-item>
  30. </a-col>
  31. <a-col :md="6" :sm="24">
  32. <a-form-model-item label="价格级别" prop="priceLevel">
  33. <v-select code="PRICE_LEVEL" id="permissionSetting-priceLevel" v-model="queryParam.priceLevel" allowClear placeholder="请选择价格级别"></v-select>
  34. </a-form-model-item>
  35. </a-col>
  36. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  37. <a-button type="primary" @click="getData" :disabled="disabled" id="permissionSetting-refresh">查询</a-button>
  38. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="permissionSetting-reset">重置</a-button>
  39. </a-col>
  40. </a-row>
  41. </a-form-model>
  42. </div>
  43. <!-- 操作按钮 -->
  44. <div class="table-operator">
  45. <a-button type="primary" id="permissionSetting-chooseType" class="button-error" @click="chooseTModal">选择品类</a-button>
  46. <span v-if="!showEmpty">
  47. <a-button type="primary" id="permissionSetting-moreEdit" v-if="$route.params.dealerLevel != 'SPECIAL'" class="button-info" @click="handleEdit()">批量编辑</a-button>
  48. <a-button type="primary" id="permissionSetting-moreDel" ghost class="button-error" @click="handleDel()">批量删除</a-button>
  49. </span>
  50. </div>
  51. <!-- 列表 -->
  52. <div :style="{height:tableHeight+'px'}">
  53. <ve-table
  54. border-y
  55. v-show="!showEmpty"
  56. :scroll-width="0"
  57. :max-height="(tableHeight)"
  58. :show-header="showTableHead"
  59. :row-style-option="{clickHighlight: true}"
  60. :cellSelectionOption="{enable: false}"
  61. :virtual-scroll-option="{enable: true}"
  62. :columns="columns"
  63. :table-data="dataSource"
  64. row-key-field-name="dealerScopeSn"
  65. :checkbox-option="checkboxOption"
  66. />
  67. <div v-show="showEmpty" class="empty-data"><a-empty description="暂无产品" :image="simpleImage"/></div>
  68. </div>
  69. </a-card>
  70. </a-spin>
  71. <!-- 选择产品分类 -->
  72. <chooseTypeModal ref="chooseType" :openModal="openTypeModal" @close="openTypeModal=false" @ok="getData" />
  73. <!-- 修改价格等级 -->
  74. <editPriceLevelModal :priceLevelVal="itemPriceLevel" :openModal="openPriceLevelModal" @close="closePriceLevelModal" @ok="handlePriceLevelOk" />
  75. </div>
  76. </template>
  77. <script>
  78. import { commonMixin } from '@/utils/mixin'
  79. // 组件
  80. import { STable, VSelect } from '@/components'
  81. import ChooseTypeModal from './chooseTypeModal.vue'
  82. import editPriceLevelModal from './priceLevelModal.vue'
  83. import productTypeAll from '@/views/common/productTypeAll.js'
  84. import ProductBrand from '@/views/common/productBrand.js'
  85. import { Empty } from 'ant-design-vue'
  86. // 接口
  87. import { dealerScopeModifyPriceLevel, dealerScopeDelete, dealerScopeQueryList } from '@/api/dealerScope'
  88. export default {
  89. name: 'MerchantInfoManagementSet',
  90. mixins: [commonMixin],
  91. components: { STable, VSelect, ChooseTypeModal, productTypeAll, ProductBrand, editPriceLevelModal },
  92. data () {
  93. return {
  94. spinning: false,
  95. tableHeight: 0, // 表格高度
  96. queryParam: { // 查询条件
  97. productBrandSn: undefined, // 产品品牌
  98. productTypeSn1: '', // 产品一级分类
  99. productTypeSn2: '', // 产品二级分类
  100. productTypeSn3: '', // 产品三级分类
  101. priceLevel: undefined// 价格级别
  102. },
  103. productType: [], // 产品分类
  104. disabled: false, // 查询、重置按钮是否可操作
  105. openTypeModal: false, // 选择产品分类
  106. openPriceLevelModal: false, // 打开修改价格等级弹窗
  107. itemPriceLevel: '', // 价格级别数据
  108. simpleImage: Empty.PRESENTED_IMAGE_SIMPLE, // 空数据图片
  109. dataSource: [], // 列表数据
  110. showEmpty: false, // 数据是否为空
  111. showTableHead: true, // 显示表头
  112. selectedRowKeys: []// 已选数据
  113. }
  114. },
  115. computed: {
  116. columns () {
  117. const _this = this
  118. // 操作按钮
  119. const actionFormat = function (record, data) {
  120. if (_this.$route.params.dealerLevel != 'SPECIAL') {
  121. return (
  122. <div>
  123. <a-button size="small" type="link" class="button-info" onClick={() => _this.handleEdit(record)}>编辑</a-button>
  124. <a-button size="small" type="link" class="button-error" onClick={() => _this.handleDel(record)}>删除</a-button>
  125. </div>
  126. )
  127. } else {
  128. return (
  129. <div>
  130. <a-button
  131. size="small"
  132. type="link"
  133. class="button-info"
  134. onClick={() => _this.handleDel(record)}
  135. >删除</a-button>
  136. </div>
  137. )
  138. }
  139. }
  140. const arr = [
  141. { title: '', field: '', key: 'acheck', width: 60, type: 'checkbox', align: 'center' },
  142. { title: '品牌', field: 'productBrandName', key: 'a', align: 'center', width: 160, operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '全品类' } },
  143. { title: '一级分类', field: 'productTypeName1', key: 'b', width: 160, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
  144. { title: '二级分类', field: 'productTypeName2', key: 'c', width: 160, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
  145. { title: '三级分类', field: 'productTypeName3', key: 'd', width: 160, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
  146. { title: '价格级别', field: 'priceLevelDictValue', key: 'e', width: 160, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
  147. { title: '操作', field: 'action', width: 100, key: 'f', align: 'center', fixed: 'right', operationColumn: false, renderBodyCell: ({ row, column }) => { return actionFormat(row, row[column.field]) } }
  148. ]
  149. return arr
  150. },
  151. // 选择列表数据
  152. checkboxOption () {
  153. const _this = this
  154. return {
  155. selectedRowKeys: _this.selectedRowKeys,
  156. // 行选择改变事件
  157. selectedRowChange: ({ row, isSelected, selectedRowKeys }) => {
  158. _this.selectedRowKeys = selectedRowKeys
  159. },
  160. // 全选改变事件
  161. selectedAllChange: ({ isSelected, selectedRowKeys }) => {
  162. _this.selectedRowKeys = selectedRowKeys
  163. }
  164. }
  165. }
  166. },
  167. methods: {
  168. // 获取列表数据
  169. getData () {
  170. const _this = this
  171. _this.disabled = true
  172. _this.spinning = true
  173. _this.queryParam.dealerSn = _this.$route.params.sn
  174. dealerScopeQueryList(_this.queryParam).then(res => {
  175. if (res.status == 200) {
  176. _this.dataSource = res.data
  177. }
  178. _this.showEmpty = _this.dataSource.length <= 0
  179. _this.disabled = false
  180. _this.spinning = false
  181. })
  182. },
  183. // 选择品类
  184. chooseTModal () {
  185. if (this.dataSource.length === 1 && this.dataSource[0] && !this.dataSource[0].productBrandSn) {
  186. this.$message.warning('该经销商的经销权已是【全品类】,请删除后重新添加!')
  187. return
  188. }
  189. this.selectedRowKeys = []
  190. this.openTypeModal = true
  191. this.$nextTick(() => {
  192. this.$refs.chooseType.getDisabledList()
  193. })
  194. },
  195. // 打开编辑弹窗
  196. handleEdit (row) {
  197. if (row) {
  198. this.selectedRowKeys = []
  199. this.selectedRowKeys.push(row.dealerScopeSn)
  200. this.itemPriceLevel = row.priceLevel
  201. } else {
  202. this.itemPriceLevel = ''
  203. if (this.selectedRowKeys && this.selectedRowKeys.length === 0) {
  204. this.$message.warning('请选择一条数据')
  205. return
  206. }
  207. }
  208. this.$nextTick(() => {
  209. this.openPriceLevelModal = true
  210. })
  211. },
  212. // 编辑价格等级
  213. handlePriceLevelOk (val) {
  214. const _this = this
  215. dealerScopeModifyPriceLevel({
  216. snList: this.selectedRowKeys,
  217. priceLevel: val
  218. }).then(res => {
  219. if (res.status == 200) {
  220. _this.$message.success(res.message)
  221. _this.resetSearchForm()
  222. _this.spinning = false
  223. } else {
  224. _this.spinning = false
  225. }
  226. })
  227. },
  228. // 关闭价格级别弹窗
  229. closePriceLevelModal () {
  230. this.itemPriceLevel = ''
  231. this.openPriceLevelModal = false
  232. },
  233. // 选择分类 change
  234. changeProductType (val, opt) {
  235. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  236. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  237. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  238. },
  239. // 批量删除
  240. handleDel (row) {
  241. const _this = this
  242. if (!row && this.selectedRowKeys && this.selectedRowKeys.length === 0) {
  243. this.$message.warning('请选择一条数据')
  244. return
  245. }
  246. const newSnList = row ? [row.dealerScopeSn] : _this.selectedRowKeys
  247. this.$confirm({
  248. title: '提示',
  249. content: '经销权删除后,该商户的差价设置将同步解除,确定删除吗?',
  250. centered: true,
  251. onOk () {
  252. _this.spinning = true
  253. dealerScopeDelete({ snList: newSnList }).then(res => {
  254. if (res.status == 200) {
  255. _this.$message.success(res.message)
  256. _this.resetSearchForm()
  257. _this.spinning = false
  258. } else {
  259. _this.spinning = false
  260. }
  261. })
  262. }
  263. })
  264. },
  265. // 重置表单
  266. resetSearchForm () {
  267. this.queryParam.productBrandSn = undefined
  268. this.queryParam.productTypeSn1 = ''
  269. this.queryParam.productTypeSn2 = ''
  270. this.queryParam.productTypeSn3 = ''
  271. this.queryParam.priceLevel = undefined
  272. this.productType = []
  273. this.getData()
  274. },
  275. // 返回
  276. handleBack () {
  277. this.selectedRowKeys = []
  278. this.$router.push({ path: '/dealerManagement/merchantInfoManagement/list', query: { closeLastOldTab: true } })
  279. },
  280. // 初始化
  281. pageInit () {
  282. const _this = this
  283. this.$nextTick(() => { // 页面渲染完成后的回调
  284. _this.setTableH()
  285. })
  286. },
  287. // 计算表格高度
  288. setTableH () {
  289. const tableSearchH = this.$refs.tableSearch.offsetHeight
  290. this.tableHeight = window.innerHeight - tableSearchH - 205
  291. }
  292. },
  293. watch: {
  294. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  295. this.setTableH()
  296. }
  297. },
  298. mounted () {
  299. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  300. this.pageInit()
  301. this.resetSearchForm()
  302. }
  303. },
  304. activated () {
  305. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  306. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  307. this.pageInit()
  308. this.resetSearchForm()
  309. }
  310. },
  311. beforeRouteEnter (to, from, next) {
  312. next(vm => {})
  313. }
  314. }
  315. </script>
  316. <style lang="less" scoped>
  317. .permissionSetting-wrap{
  318. .permissionSetting-cont{
  319. margin-bottom: 6px;
  320. }
  321. .empty-data{
  322. padding-top:100px;
  323. }
  324. }
  325. /deep/.ve-checkbox .ve-checkbox-checked .ve-checkbox-inner {
  326. background-color: #ed1c24 !important;
  327. border-color: #ed1c24 !important;
  328. }
  329. /deep/.ve-checkbox .ve-checkbox-indeterminate .ve-checkbox-inner::after{
  330. background-color: #ed1c24 !important;
  331. }
  332. </style>