permissionSettingNew.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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-info" @click="chooseTModal">选择品类</a-button>
  46. <span v-if="!showEmpty && $route.params.dealerLevel != 'special'">
  47. <a-button type="primary" class="button-success" @click="handleEdit()">批量编辑</a-button>
  48. <a-button type="primary" 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="resetSearchForm" />
  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, h) {
  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: 'action', width: 100, key: 'e', align: 'center', fixed: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return actionFormat(row, row[column.field], h) } }
  145. ]
  146. return arr
  147. },
  148. checkboxOption () {
  149. const _this = this
  150. return {
  151. selectedRowKeys: _this.selectedRowKeys,
  152. // 行选择改变事件
  153. selectedRowChange: ({ row, isSelected, selectedRowKeys }) => {
  154. _this.selectedRowKeys = selectedRowKeys
  155. },
  156. // 全选改变事件
  157. selectedAllChange: ({ isSelected, selectedRowKeys }) => {
  158. _this.selectedRowKeys = selectedRowKeys
  159. }
  160. }
  161. }
  162. },
  163. methods: {
  164. getData () {
  165. const _this = this
  166. _this.disabled = true
  167. _this.spinning = true
  168. _this.queryParam.dealerSn = _this.$route.params.sn
  169. dealerScopeQueryList(_this.queryParam).then(res => {
  170. if (res.status == 200) {
  171. _this.dataSource = res.data
  172. }
  173. _this.showEmpty = _this.dataSource.length <= 0
  174. _this.disabled = false
  175. _this.spinning = false
  176. })
  177. },
  178. // 选择品类
  179. chooseTModal () {
  180. this.openTypeModal = true
  181. this.$nextTick(() => {
  182. this.$refs.chooseType.getDisabledList()
  183. })
  184. },
  185. // 打开编辑弹窗
  186. handleEdit (row) {
  187. if (row) {
  188. this.selectedRowKeys = []
  189. this.selectedRowKeys.push(row.dealerScopeSn)
  190. this.itemPriceLevel = row.priceLevel
  191. } else {
  192. this.itemPriceLevel = ''
  193. if (this.selectedRowKeys && this.selectedRowKeys.length === 0) {
  194. this.$message.warning('请选择一条数据')
  195. return
  196. }
  197. }
  198. this.$nextTick(() => {
  199. this.openPriceLevelModal = true
  200. })
  201. },
  202. // 编辑价格等级
  203. handlePriceLevelOk (val) {
  204. const _this = this
  205. dealerScopeModifyPriceLevel({
  206. snList: this.selectedRowKeys,
  207. priceLevel: val
  208. }).then(res => {
  209. if (res.status == 200) {
  210. _this.$message.success(res.message)
  211. _this.resetSearchForm()
  212. _this.spinning = false
  213. } else {
  214. _this.spinning = false
  215. }
  216. })
  217. },
  218. closePriceLevelModal () {
  219. this.itemPriceLevel = ''
  220. this.openPriceLevelModal = false
  221. },
  222. // 选择分类 change
  223. changeProductType (val, opt) {
  224. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  225. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  226. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  227. },
  228. // 批量删除
  229. handleDel (row) {
  230. const _this = this
  231. if (!row && this.selectedRowKeys && this.selectedRowKeys.length === 0) {
  232. this.$message.warning('请选择一条数据')
  233. return
  234. }
  235. const newSnList = row ? [row.dealerScopeSn] : _this.selectedRowKeys
  236. this.$confirm({
  237. title: '提示',
  238. content: '经销权删除后,该商户的差价设置将同步解除,确定删除吗?',
  239. centered: true,
  240. onOk () {
  241. _this.spinning = true
  242. dealerScopeDelete({ snList: newSnList }).then(res => {
  243. if (res.status == 200) {
  244. _this.$message.success(res.message)
  245. _this.resetSearchForm()
  246. _this.spinning = false
  247. } else {
  248. _this.spinning = false
  249. }
  250. })
  251. }
  252. })
  253. },
  254. // 重置表单
  255. resetSearchForm () {
  256. this.queryParam.productBrandSn = undefined
  257. this.queryParam.productTypeSn1 = ''
  258. this.queryParam.productTypeSn2 = ''
  259. this.queryParam.productTypeSn3 = ''
  260. this.queryParam.priceLevel = undefined
  261. this.productType = []
  262. this.getData()
  263. },
  264. // 返回
  265. handleBack () {
  266. this.selectedRowKeys = []
  267. this.$router.push({ path: '/dealerManagement/merchantInfoManagement/list', query: { closeLastOldTab: true } })
  268. },
  269. pageInit () {
  270. const _this = this
  271. this.$nextTick(() => { // 页面渲染完成后的回调
  272. _this.setTableH()
  273. })
  274. },
  275. setTableH () {
  276. const tableSearchH = this.$refs.tableSearch.offsetHeight
  277. this.tableHeight = window.innerHeight - tableSearchH - 205
  278. }
  279. },
  280. watch: {
  281. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  282. this.setTableH()
  283. }
  284. },
  285. mounted () {
  286. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  287. this.pageInit()
  288. this.resetSearchForm()
  289. }
  290. },
  291. activated () {
  292. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  293. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  294. this.pageInit()
  295. this.resetSearchForm()
  296. }
  297. },
  298. beforeRouteEnter (to, from, next) {
  299. next(vm => {})
  300. }
  301. }
  302. </script>
  303. <style lang="less" scoped>
  304. .permissionSetting-wrap{
  305. .permissionSetting-cont{
  306. margin-bottom: 6px;
  307. }
  308. .empty-data{
  309. padding-top:100px;
  310. }
  311. }
  312. /deep/.ve-checkbox .ve-checkbox-checked .ve-checkbox-inner {
  313. background-color: #ed1c24 !important;
  314. border-color: #ed1c24 !important;
  315. }
  316. /deep/.ve-checkbox .ve-checkbox-indeterminate .ve-checkbox-inner::after{
  317. background-color: #ed1c24 !important;
  318. }
  319. </style>