permissionSettingNew.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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="chooseProducts-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="chooseProducts-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="productLevelEdit-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" class="button-error" @click="chooseTModal">选择品类</a-button>
  46. <span v-if="!showEmpty">
  47. <a-button type="primary" v-if="$route.params.dealerLevel != 'SPECIAL'" class="button-info" @click="handleEdit()">批量编辑</a-button>
  48. <a-button type="primary" 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. import { STable, VSelect } from '@/components'
  80. import ChooseTypeModal from './chooseTypeModal.vue'
  81. import editPriceLevelModal from './priceLevelModal.vue'
  82. import productTypeAll from '@/views/common/productTypeAll.js'
  83. import ProductBrand from '@/views/common/productBrand.js'
  84. import { Empty } from 'ant-design-vue'
  85. import { dealerScopeModifyPriceLevel, dealerScopeDelete, dealerScopeQueryList } from '@/api/dealerScope'
  86. export default {
  87. name: 'MerchantInfoManagementSet',
  88. mixins: [commonMixin],
  89. components: { STable, VSelect, ChooseTypeModal, productTypeAll, ProductBrand, editPriceLevelModal },
  90. data () {
  91. return {
  92. spinning: false,
  93. tableHeight: 0,
  94. queryParam: { // 查询条件
  95. productBrandSn: undefined, // 产品品牌
  96. productTypeSn1: '', // 产品一级分类
  97. productTypeSn2: '', // 产品二级分类
  98. productTypeSn3: '', // 产品三级分类
  99. priceLevel: undefined
  100. },
  101. productType: [],
  102. disabled: false, // 查询、重置按钮是否可操作
  103. openTypeModal: false, // 选择产品分类
  104. openPriceLevelModal: false,
  105. itemPriceLevel: '',
  106. simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
  107. dataSource: [],
  108. showEmpty: false,
  109. showTableHead: true, // 显示表头
  110. selectedRowKeys: []
  111. }
  112. },
  113. computed: {
  114. columns () {
  115. const _this = this
  116. // 操作按钮
  117. const actionFormat = function (record, data) {
  118. if (_this.$route.params.dealerLevel != 'SPECIAL') {
  119. return (
  120. <div>
  121. <a-button size="small" type="link" class="button-info" onClick={() => _this.handleEdit(record)}>编辑</a-button>
  122. <a-button size="small" type="link" class="button-error" onClick={() => _this.handleDel(record)}>删除</a-button>
  123. </div>
  124. )
  125. } else {
  126. return (
  127. <div>
  128. <a-button
  129. size="small"
  130. type="link"
  131. class="button-info"
  132. onClick={() => _this.handleDel(record)}
  133. >删除</a-button>
  134. </div>
  135. )
  136. }
  137. }
  138. const arr = [
  139. { title: '', field: '', key: 'acheck', width: 60, type: 'checkbox', align: 'center' },
  140. { title: '品牌', field: 'productBrandName', key: 'a', align: 'center', width: 160, operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '全品类' } },
  141. { title: '一级分类', field: 'productTypeName1', key: 'b', width: 160, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
  142. { title: '二级分类', field: 'productTypeName2', key: 'c', width: 160, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
  143. { title: '三级分类', field: 'productTypeName3', key: 'd', width: 160, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
  144. { title: '价格级别', field: 'priceLevelDictValue', key: 'd', width: 160, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
  145. { title: '操作', field: 'action', width: 100, key: 'e', align: 'center', fixed: 'right', operationColumn: false, renderBodyCell: ({ row, column }) => { return actionFormat(row, row[column.field]) } }
  146. ]
  147. return arr
  148. },
  149. checkboxOption () {
  150. const _this = this
  151. return {
  152. selectedRowKeys: _this.selectedRowKeys,
  153. // 行选择改变事件
  154. selectedRowChange: ({ row, isSelected, selectedRowKeys }) => {
  155. _this.selectedRowKeys = selectedRowKeys
  156. },
  157. // 全选改变事件
  158. selectedAllChange: ({ isSelected, selectedRowKeys }) => {
  159. _this.selectedRowKeys = selectedRowKeys
  160. }
  161. }
  162. }
  163. },
  164. methods: {
  165. getData () {
  166. const _this = this
  167. _this.disabled = true
  168. _this.spinning = true
  169. _this.queryParam.dealerSn = _this.$route.params.sn
  170. dealerScopeQueryList(_this.queryParam).then(res => {
  171. if (res.status == 200) {
  172. _this.dataSource = res.data
  173. }
  174. _this.showEmpty = _this.dataSource.length <= 0
  175. _this.disabled = false
  176. _this.spinning = false
  177. })
  178. },
  179. // 选择品类
  180. chooseTModal () {
  181. if (this.dataSource.length === 1 && this.dataSource[0] && !this.dataSource[0].productBrandSn) {
  182. this.$message.warning('选择全品类后,不能再添加其他品类!')
  183. return
  184. }
  185. this.selectedRowKeys = []
  186. this.openTypeModal = true
  187. this.$nextTick(() => {
  188. this.$refs.chooseType.getDisabledList()
  189. })
  190. },
  191. // 打开编辑弹窗
  192. handleEdit (row) {
  193. if (row) {
  194. this.selectedRowKeys = []
  195. this.selectedRowKeys.push(row.dealerScopeSn)
  196. this.itemPriceLevel = row.priceLevel
  197. } else {
  198. this.itemPriceLevel = ''
  199. if (this.selectedRowKeys && this.selectedRowKeys.length === 0) {
  200. this.$message.warning('请选择一条数据')
  201. return
  202. }
  203. }
  204. this.$nextTick(() => {
  205. this.openPriceLevelModal = true
  206. })
  207. },
  208. // 编辑价格等级
  209. handlePriceLevelOk (val) {
  210. const _this = this
  211. dealerScopeModifyPriceLevel({
  212. snList: this.selectedRowKeys,
  213. priceLevel: val
  214. }).then(res => {
  215. if (res.status == 200) {
  216. _this.$message.success(res.message)
  217. _this.resetSearchForm()
  218. _this.spinning = false
  219. } else {
  220. _this.spinning = false
  221. }
  222. })
  223. },
  224. closePriceLevelModal () {
  225. this.itemPriceLevel = ''
  226. this.openPriceLevelModal = false
  227. },
  228. // 选择分类 change
  229. changeProductType (val, opt) {
  230. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  231. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  232. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  233. },
  234. // 批量删除
  235. handleDel (row) {
  236. const _this = this
  237. if (!row && this.selectedRowKeys && this.selectedRowKeys.length === 0) {
  238. this.$message.warning('请选择一条数据')
  239. return
  240. }
  241. const newSnList = row ? [row.dealerScopeSn] : _this.selectedRowKeys
  242. this.$confirm({
  243. title: '提示',
  244. content: '经销权删除后,该商户的差价设置将同步解除,确定删除吗?',
  245. centered: true,
  246. onOk () {
  247. _this.spinning = true
  248. dealerScopeDelete({ snList: newSnList }).then(res => {
  249. if (res.status == 200) {
  250. _this.$message.success(res.message)
  251. _this.resetSearchForm()
  252. _this.spinning = false
  253. } else {
  254. _this.spinning = false
  255. }
  256. })
  257. }
  258. })
  259. },
  260. // 重置表单
  261. resetSearchForm () {
  262. this.queryParam.productBrandSn = undefined
  263. this.queryParam.productTypeSn1 = ''
  264. this.queryParam.productTypeSn2 = ''
  265. this.queryParam.productTypeSn3 = ''
  266. this.queryParam.priceLevel = undefined
  267. this.productType = []
  268. this.getData()
  269. },
  270. // 返回
  271. handleBack () {
  272. this.selectedRowKeys = []
  273. this.$router.push({ path: '/dealerManagement/merchantInfoManagement/list', query: { closeLastOldTab: true } })
  274. },
  275. pageInit () {
  276. const _this = this
  277. this.$nextTick(() => { // 页面渲染完成后的回调
  278. _this.setTableH()
  279. })
  280. },
  281. setTableH () {
  282. const tableSearchH = this.$refs.tableSearch.offsetHeight
  283. this.tableHeight = window.innerHeight - tableSearchH - 205
  284. }
  285. },
  286. watch: {
  287. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  288. this.setTableH()
  289. }
  290. },
  291. mounted () {
  292. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  293. this.pageInit()
  294. this.resetSearchForm()
  295. }
  296. },
  297. activated () {
  298. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  299. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  300. this.pageInit()
  301. this.resetSearchForm()
  302. }
  303. },
  304. beforeRouteEnter (to, from, next) {
  305. next(vm => {})
  306. }
  307. }
  308. </script>
  309. <style lang="less" scoped>
  310. .permissionSetting-wrap{
  311. .permissionSetting-cont{
  312. margin-bottom: 6px;
  313. }
  314. .empty-data{
  315. padding-top:100px;
  316. }
  317. }
  318. /deep/.ve-checkbox .ve-checkbox-checked .ve-checkbox-inner {
  319. background-color: #ed1c24 !important;
  320. border-color: #ed1c24 !important;
  321. }
  322. /deep/.ve-checkbox .ve-checkbox-indeterminate .ve-checkbox-inner::after{
  323. background-color: #ed1c24 !important;
  324. }
  325. </style>