list.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <div class="rebateBinding-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" @back="handleBack" class="rebateBinding-cont">
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="rebateBinding-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <span style="margin-left: 20px;color: #666;" v-if="detail">经销商:{{ detail.dealerName }}</span>
  9. </template>
  10. </a-page-header>
  11. <a-card size="small" :bordered="false" class="rebateBinding-main">
  12. <!-- 搜索条件 -->
  13. <div ref="tableSearch" class="table-page-search-wrapper">
  14. <a-form-model
  15. id="rebateBinding-form"
  16. v-show="!isTeyue"
  17. ref="ruleForm"
  18. class="form-model-con"
  19. layout="inline"
  20. :model="queryParam"
  21. @keyup.enter.native="handleSearch">
  22. <a-row :gutter="15">
  23. <a-col :md="6" :sm="24">
  24. <a-form-model-item label="品牌">
  25. <ProductBrand id="rebateBinding-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  26. </a-form-model-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-model-item label="产品分类">
  30. <ProductType id="rebateBinding-productType" placeholder="请选择产品分类" @change="changeProductType" v-model="productType"></ProductType>
  31. </a-form-model-item>
  32. </a-col>
  33. <!-- <a-col :md="6" :sm="24" v-if="!isTeyue">
  34. <a-form-model-item label="价格级别">
  35. <v-select code="PRICE_LEVEL" :notIn="['SPECIAL']" v-model="queryParam.priceLevel" allowClear placeholder="请选择价格级别"></v-select>
  36. </a-form-model-item>
  37. </a-col>
  38. <a-col :md="6" :sm="24" v-if="!isTeyue">
  39. <a-form-model-item label="经销商">
  40. <a-input v-model.trim="queryParam.dealerName" allowClear placeholder="请输入经销商名称"/>
  41. </a-form-model-item>
  42. </a-col> -->
  43. <a-col :md="6" :sm="24" v-show="false">
  44. <a-form-model-item label="差价归属方">
  45. <v-select
  46. id="rebateBinding-rebateParentType"
  47. code="REBATE_PARENT_TYPE"
  48. ref="rpType"
  49. v-model="queryParam.rebateParentType"
  50. allowClear
  51. placeholder="请选择差价归属方"></v-select>
  52. </a-form-model-item>
  53. </a-col>
  54. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  55. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="rebateBinding-refresh">查询</a-button>
  56. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="rebateBinding-reset">重置</a-button>
  57. </a-col>
  58. </a-row>
  59. </a-form-model>
  60. </div>
  61. <!-- 操作按钮 -->
  62. <div class="table-operator" style="display: flex;align-items: center;justify-content: space-between;" v-if="showBtns">
  63. <a-button id="rebateBinding-brand" type="primary" class="button-error" @click="openGlModal">差价设置</a-button>
  64. <div v-if="!isTeyue && hasData">
  65. <a-button id="rebateBinding-isTeyue" type="default" @click="expandAllRow">{{ expandAll?'收起全部':'展开全部' }}</a-button>
  66. </div>
  67. </div>
  68. <!-- 列表 -->
  69. <categoryList ref="categoryList" @loaded="loadList" @del="delOk" @edit="handleEdit" :maxHeight="tableHeight"></categoryList>
  70. </a-card>
  71. </a-spin>
  72. <!-- 差价设置 -->
  73. <priceDiffModal ref="priceDiffModal" :openModal="openModal" @ok="resetGetData" @close="openModal=false"></pricediffmodal>
  74. </div>
  75. </template>
  76. <script>
  77. import { commonMixin } from '@/utils/mixin'
  78. // 组件
  79. import { STable, VSelect } from '@/components'
  80. import ProductType from '@/views/common/productType.js'
  81. import ProductBrand from '@/views/common/productBrand.js'
  82. import priceDiffModal from './priceDiffModal.vue'
  83. import categoryList from './categoryList'
  84. // 接口
  85. import { dealerDetailBySn } from '@/api/dealer'
  86. export default {
  87. name: 'RebateBinding',
  88. mixins: [commonMixin],
  89. components: { STable, VSelect, ProductType, ProductBrand, priceDiffModal, categoryList },
  90. data () {
  91. return {
  92. spinning: false,
  93. tableHeight: 0, // 表格高度
  94. disabled: false, // 查询、重置按钮是否可操作
  95. loading: false, // 表格加载中
  96. openModal: false, // 差价设置弹窗
  97. detail: null, // 详情数据
  98. productType: [], // 产品分类查询数据
  99. // 查询条件
  100. queryParam: {
  101. rebateParentType: undefined, // 差价归属方
  102. priceLevel: undefined, // 价格级别
  103. productBrandSn: undefined, // 品牌
  104. productTypeSn1: undefined, // 产品一级分类
  105. productTypeSn2: undefined, // 产品二级分类
  106. productTypeSn3: undefined, // 产品三级分类
  107. dealerName: ''// 经销商名称
  108. },
  109. showBtns: true, // 是否显示操作按钮
  110. expandAll: false, // 显示展开全部 收起全部按钮
  111. hasData: false // 列表数据是否为空
  112. }
  113. },
  114. computed: {
  115. // 判断是否显示特约经销商内容
  116. isTeyue () {
  117. return this.detail && this.detail.dealerLevel == 'SPECIAL'
  118. }
  119. },
  120. methods: {
  121. // 返回
  122. handleBack () {
  123. this.$router.push({ name: 'merchantInfoManagementList', query: { closeLastOldTab: true } })
  124. },
  125. // 获取列表数据
  126. loadList (list) {
  127. this.showBtns = this.isTeyue ? list.length == 0 : true
  128. this.hasData = list.length > 0
  129. this.$nextTick(() => {
  130. if (!this.expandAll) {
  131. this.expandAllRow()
  132. }
  133. })
  134. },
  135. // 查询
  136. handleSearch () {
  137. this.queryParam.dealerSn = this.$route.params.sn
  138. const params = {}
  139. for (const k in this.queryParam) {
  140. if (this.queryParam[k]) {
  141. params[k] = this.queryParam[k]
  142. }
  143. }
  144. this.$refs.categoryList.pageInit(params, this.isTeyue)
  145. },
  146. // 产品分类 change
  147. changeProductType (val, opt) {
  148. this.queryParam.productTypeSn1 = val[0] ? val[0] : undefined
  149. this.queryParam.productTypeSn2 = val[1] ? val[1] : undefined
  150. this.queryParam.productTypeSn3 = val[2] ? val[2] : undefined
  151. },
  152. // 收起全部 展开全部 事件
  153. expandAllRow () {
  154. if (this.expandAll) {
  155. this.$refs.categoryList.foldAll()
  156. } else {
  157. this.$refs.categoryList.expandAll()
  158. }
  159. this.expandAll = !this.expandAll
  160. },
  161. // 差价设置成功,关闭弹窗,初始化弹窗所需数据
  162. resetGetData () {
  163. this.expandAll = false
  164. this.$refs.categoryList.dataSource = []
  165. this.resetSearchForm()
  166. },
  167. // 重置表单
  168. resetSearchForm () {
  169. this.queryParam.dealerName = ''
  170. this.queryParam.rebateParentType = undefined
  171. this.queryParam.priceLevel = undefined
  172. this.queryParam.productBrandSn = undefined
  173. this.queryParam.productTypeSn1 = undefined
  174. this.queryParam.productTypeSn2 = undefined
  175. this.queryParam.productTypeSn3 = undefined
  176. this.productType = []
  177. this.handleSearch()
  178. this.openModal = false
  179. },
  180. // 打开关联弹框
  181. openGlModal () {
  182. this.openModal = true
  183. const checkedDealerSn = this.$refs.categoryList.checkedDealerSn
  184. this.$refs.priceDiffModal.setData(this.$refs.rpType.getOptionDatas(), this.$route.params.sn, this.detail, checkedDealerSn)
  185. },
  186. // 编辑
  187. handleEdit (row) {
  188. this.openModal = true
  189. this.$refs.priceDiffModal.editData(this.$refs.rpType.getOptionDatas(), this.$route.params.sn, this.detail, row)
  190. },
  191. // 删除成功
  192. delOk () {
  193. this.handleSearch()
  194. },
  195. // 详情
  196. getDetail () {
  197. this.spinning = true
  198. dealerDetailBySn({ sn: this.$route.params.sn }).then(res => {
  199. if (res.status == 200) {
  200. this.detail = res.data
  201. this.handleSearch()
  202. }
  203. this.spinning = false
  204. })
  205. },
  206. // 初始化
  207. pageInit () {
  208. const _this = this
  209. this.getDetail()
  210. this.$nextTick(() => { // 页面渲染完成后的回调
  211. _this.setTableH()
  212. })
  213. },
  214. // 获取表格高度
  215. setTableH () {
  216. const tableSearchH = this.$refs.tableSearch.offsetHeight
  217. this.tableHeight = window.innerHeight - tableSearchH - (!this.showBtns ? 50 : 205)
  218. }
  219. },
  220. watch: {
  221. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  222. this.setTableH()
  223. }
  224. },
  225. mounted () {
  226. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  227. this.pageInit()
  228. }
  229. },
  230. activated () {
  231. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  232. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  233. this.pageInit()
  234. }
  235. },
  236. beforeRouteEnter (to, from, next) {
  237. next(vm => {})
  238. }
  239. }
  240. </script>
  241. <style lang="less" scoped>
  242. .rebateBinding-wrap{
  243. .rebateBinding-cont{
  244. margin-bottom: 6px;
  245. }
  246. }
  247. </style>