permissionSettingNew.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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 id="permissionSetting-brand" type="primary" class="button-error" @click="chooseTModal">选择品类</a-button>
  46. </div>
  47. <!-- 列表 -->
  48. <div :style="{height:tableHeight+'px'}">
  49. <ve-table
  50. border-y
  51. v-show="!showEmpty"
  52. :scroll-width="0"
  53. :max-height="(tableHeight)"
  54. :show-header="showTableHead"
  55. :row-style-option="{clickHighlight: true}"
  56. :cellSelectionOption="{enable: false}"
  57. :virtual-scroll-option="{enable: true}"
  58. :columns="columns"
  59. :table-data="dataSource"
  60. row-key-field-name="no"
  61. :checkbox-option="checkboxOption"
  62. />
  63. <div v-show="showEmpty" class="empty-data"><a-empty description="暂无产品" :image="simpleImage"/></div>
  64. </div>
  65. </a-card>
  66. </a-spin>
  67. <!-- 选择产品分类 -->
  68. <chooseTypeModal :openModal="openTypeModal" @close="openTypeModal=false" @ok="handleTypeOk" />
  69. <!-- 修改价格等级 -->
  70. <editPriceLevelModal :priceLevelVal="itemPriceLevel" :openModal="openPriceLevelModal" @close="closePriceLevelModal" @ok="handlePriceLevelOk" />
  71. </div>
  72. </template>
  73. <script>
  74. import { commonMixin } from '@/utils/mixin'
  75. import { STable, VSelect } from '@/components'
  76. import ChooseTypeModal from './chooseTypeModal.vue'
  77. import editPriceLevelModal from './priceLevelModal.vue'
  78. import productTypeAll from '@/views/common/productTypeAll.js'
  79. import ProductBrand from '@/views/common/productBrand.js'
  80. import { Empty } from 'ant-design-vue'
  81. import { dealerScopeModifyPriceLevel, dealerScopeDelete, dealerScopeQueryList } from '@/api/dealerScope'
  82. export default {
  83. name: 'MerchantInfoManagementSet',
  84. mixins: [commonMixin],
  85. components: { STable, VSelect, ChooseTypeModal, productTypeAll, ProductBrand, editPriceLevelModal },
  86. data () {
  87. return {
  88. spinning: false,
  89. tableHeight: 0,
  90. queryParam: { // 查询条件
  91. productBrandSn: undefined, // 产品品牌
  92. productTypeSn1: '', // 产品一级分类
  93. productTypeSn2: '', // 产品二级分类
  94. productTypeSn3: '', // 产品三级分类
  95. priceLevel: undefined
  96. },
  97. productType: [],
  98. disabled: false, // 查询、重置按钮是否可操作
  99. loading: false, // 表格加载中
  100. openTypeModal: false, // 选择产品分类
  101. chooseType: [], // 所选分类
  102. openPriceLevelModal: false,
  103. itemSn: null,
  104. itemPriceLevel: '',
  105. simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
  106. dataSource: [],
  107. showEmpty: false,
  108. showTableHead: true, // 显示表头
  109. checkboxOption: {
  110. // 行选择改变事件
  111. selectedRowChange: ({ row, isSelected, selectedRowKeys }) => {
  112. console.log(row, isSelected, selectedRowKeys)
  113. },
  114. // 全选改变事件
  115. selectedAllChange: ({ isSelected, selectedRowKeys }) => {
  116. console.log(isSelected, selectedRowKeys)
  117. }
  118. }
  119. }
  120. },
  121. computed: {
  122. columns () {
  123. const _this = this
  124. // 操作按钮
  125. const actionFormat = function (record, data, h) {
  126. if (_this.$route.params.dealerLevel != 'special') {
  127. return (
  128. <div>
  129. <a-button size="small" type="link" class="button-info" onClick={() => _this.handleEdit(record)}>编辑</a-button>
  130. <a-button size="small" type="link" class="button-info" onClick={() => _this.handleDel(record)}>删除</a-button>
  131. </div>
  132. )
  133. } else {
  134. return (
  135. <div>
  136. <a-button
  137. size="small"
  138. type="link"
  139. class="button-info"
  140. onClick={() => _this.handleDel(record)}
  141. >删除</a-button>
  142. </div>
  143. )
  144. }
  145. }
  146. const arr = [
  147. { title: '', field: '', key: 'acheck', width: 60, type: 'checkbox', align: 'center' },
  148. { title: '品牌', field: 'productBrandName', key: 'a', align: 'center', width: 160, operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
  149. { title: '一级分类', field: 'productTypeName1', key: 'b', width: 160, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
  150. { title: '二级分类', field: 'productTypeName2', key: 'c', width: 160, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
  151. { title: '三级分类', field: 'productTypeName3', key: 'd', width: 160, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
  152. { 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) } }
  153. ]
  154. return arr
  155. }
  156. },
  157. methods: {
  158. getData () {
  159. const _this = this
  160. _this.disabled = true
  161. _this.spinning = true
  162. _this.queryParam.dealerSn = _this.$route.params.sn
  163. dealerScopeQueryList(_this.queryParam).then(res => {
  164. if (res.status == 200) {
  165. _this.dataSource = res.data
  166. }
  167. _this.showEmpty = _this.dataSource.length <= 0
  168. _this.disabled = false
  169. _this.spinning = false
  170. })
  171. },
  172. // 选择品类
  173. chooseTModal () {
  174. this.openTypeModal = true
  175. },
  176. // 打开编辑弹窗
  177. handleEdit (row) {
  178. this.itemSn = row.dealerScopeSn
  179. this.itemPriceLevel = row.priceLevel
  180. this.$nextTick(() => {
  181. this.openPriceLevelModal = true
  182. })
  183. },
  184. // 编辑价格等级
  185. handlePriceLevelOk (val) {
  186. const _this = this
  187. dealerScopeModifyPriceLevel({ dealerScopeSn: this.itemSn, priceLevel: val }).then(res => {
  188. if (res.status == 200) {
  189. _this.$message.success(res.message)
  190. _this.spinning = false
  191. } else {
  192. _this.spinning = false
  193. }
  194. })
  195. },
  196. closePriceLevelModal () {
  197. this.itemPriceLevel = ''
  198. this.itemSn = null
  199. this.openPriceLevelModal = false
  200. },
  201. // 选择分类 change
  202. changeProductType (val, opt) {
  203. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  204. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  205. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  206. },
  207. // 选择品类完成
  208. handleTypeOk (obj) {
  209. // this.$refs.table.refresh(true)
  210. },
  211. // 删除
  212. handleDel (row) {
  213. const _this = this
  214. this.$confirm({
  215. title: '提示',
  216. content: '删除后无法向总部或上级采购,确认删除吗?',
  217. centered: true,
  218. onOk () {
  219. _this.spinning = true
  220. dealerScopeDelete({ dealerScopeSn: row.dealerScopeSn }).then(res => {
  221. if (res.status == 200) {
  222. _this.$message.success(res.message)
  223. // _this.$refs.table.refresh()
  224. _this.spinning = false
  225. } else {
  226. _this.spinning = false
  227. }
  228. })
  229. }
  230. })
  231. },
  232. // 重置表单
  233. resetSearchForm () {
  234. this.queryParam.productBrandSn = undefined
  235. this.queryParam.productTypeSn1 = ''
  236. this.queryParam.productTypeSn2 = ''
  237. this.queryParam.productTypeSn3 = ''
  238. this.queryParam.priceLevel = undefined
  239. this.productType = []
  240. this.getData()
  241. },
  242. // 返回
  243. handleBack () {
  244. this.$router.push({ path: '/dealerManagement/merchantInfoManagement/list', query: { closeLastOldTab: true } })
  245. },
  246. pageInit () {
  247. const _this = this
  248. this.$nextTick(() => { // 页面渲染完成后的回调
  249. _this.setTableH()
  250. })
  251. },
  252. setTableH () {
  253. const tableSearchH = this.$refs.tableSearch.offsetHeight
  254. this.tableHeight = window.innerHeight - tableSearchH - 205
  255. }
  256. },
  257. watch: {
  258. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  259. this.setTableH()
  260. }
  261. },
  262. mounted () {
  263. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  264. this.pageInit()
  265. this.resetSearchForm()
  266. }
  267. },
  268. activated () {
  269. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  270. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  271. this.pageInit()
  272. this.resetSearchForm()
  273. }
  274. },
  275. beforeRouteEnter (to, from, next) {
  276. next(vm => {})
  277. }
  278. }
  279. </script>
  280. <style lang="less" scoped>
  281. .permissionSetting-wrap{
  282. .permissionSetting-cont{
  283. margin-bottom: 6px;
  284. }
  285. .empty-data{
  286. padding-top:100px;
  287. }
  288. }
  289. /deep/.ve-checkbox .ve-checkbox-checked .ve-checkbox-inner {
  290. background-color: #ed1c24 !important;
  291. border-color: #ed1c24 !important;
  292. }
  293. /deep/.ve-checkbox .ve-checkbox-indeterminate .ve-checkbox-inner::after{
  294. background-color: #ed1c24 !important;
  295. }
  296. </style>