list.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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 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 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 code="REBATE_PARENT_TYPE" ref="rpType" v-model="queryParam.rebateParentType" allowClear placeholder="请选择差价归属方"></v-select>
  46. </a-form-model-item>
  47. </a-col>
  48. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  49. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="rebateBinding-refresh">查询</a-button>
  50. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="rebateBinding-reset">重置</a-button>
  51. </a-col>
  52. </a-row>
  53. </a-form-model>
  54. </div>
  55. <!-- 操作按钮 -->
  56. <div class="table-operator" v-if="showBtns">
  57. <a-button id="rebateBinding-brand" type="primary" class="button-error" @click="openGlModal">差价设置</a-button>
  58. </div>
  59. <!-- 列表 -->
  60. <categoryList ref="categoryList" @loaded="loadList" @del="delOk" @edit="handleEdit" :maxHeight="tableHeight"></categoryList>
  61. </a-card>
  62. </a-spin>
  63. <!-- 差价设置 -->
  64. <priceDiffModal ref="priceDiffModal" :openModal="openModal" @ok="resetSearchForm" @close="openModal=false"></pricediffmodal>
  65. </div>
  66. </template>
  67. <script>
  68. import { commonMixin } from '@/utils/mixin'
  69. import { STable, VSelect } from '@/components'
  70. import { dealerDetailBySn } from '@/api/dealer'
  71. import ProductType from '@/views/common/productType.js'
  72. import ProductBrand from '@/views/common/productBrand.js'
  73. import priceDiffModal from './priceDiffModal.vue'
  74. import categoryList from './categoryList'
  75. export default {
  76. name: 'RebateBinding',
  77. mixins: [commonMixin],
  78. components: { STable, VSelect, ProductType, ProductBrand, priceDiffModal, categoryList },
  79. data () {
  80. return {
  81. spinning: false,
  82. tableHeight: 0,
  83. disabled: false, // 查询、重置按钮是否可操作
  84. loading: false, // 表格加载中
  85. openModal: false,
  86. detail: null,
  87. productType: [],
  88. queryParam: { // 查询条件
  89. rebateParentType: undefined,
  90. priceLevel: undefined,
  91. productBrandSn: undefined,
  92. productTypeSn1: undefined,
  93. productTypeSn2: undefined,
  94. productTypeSn3: undefined,
  95. dealerName: ''
  96. },
  97. showBtns: true
  98. }
  99. },
  100. computed: {
  101. isTeyue () {
  102. return this.detail && this.detail.dealerLevel == 'SPECIAL'
  103. }
  104. },
  105. methods: {
  106. // 返回
  107. handleBack () {
  108. this.$router.push({ name: 'merchantInfoManagementList', query: { closeLastOldTab: true } })
  109. },
  110. loadList (list) {
  111. console.log(list.length == 0)
  112. this.showBtns = this.isTeyue ? list.length == 0 : true
  113. },
  114. // 查询
  115. handleSearch () {
  116. this.queryParam.dealerSn = this.$route.params.sn
  117. const params = {}
  118. for (const k in this.queryParam) {
  119. if (this.queryParam[k]) {
  120. params[k] = this.queryParam[k]
  121. }
  122. }
  123. this.$refs.categoryList.pageInit(params)
  124. },
  125. // 产品分类 change
  126. changeProductType (val, opt) {
  127. this.queryParam.productTypeSn1 = val[0] ? val[0] : undefined
  128. this.queryParam.productTypeSn2 = val[1] ? val[1] : undefined
  129. this.queryParam.productTypeSn3 = val[2] ? val[2] : undefined
  130. },
  131. // 重置表单
  132. resetSearchForm () {
  133. this.queryParam.dealerName = ''
  134. this.queryParam.rebateParentType = undefined
  135. this.queryParam.priceLevel = undefined
  136. this.queryParam.productBrandSn = undefined
  137. this.queryParam.productTypeSn1 = undefined
  138. this.queryParam.productTypeSn2 = undefined
  139. this.queryParam.productTypeSn3 = undefined
  140. this.productType = []
  141. this.handleSearch()
  142. this.openModal = false
  143. },
  144. // 打开关联弹框
  145. openGlModal () {
  146. this.openModal = true
  147. const checkedDealerSn = this.$refs.categoryList.checkedDealerSn
  148. this.$refs.priceDiffModal.setData(this.$refs.rpType.getOptionDatas(), this.$route.params.sn, this.detail, checkedDealerSn)
  149. },
  150. // 编辑
  151. handleEdit (row) {
  152. this.openModal = true
  153. this.$refs.priceDiffModal.editData(this.$refs.rpType.getOptionDatas(), this.$route.params.sn, this.detail, row)
  154. },
  155. // 删除成功
  156. delOk () {
  157. this.handleSearch()
  158. },
  159. // 详情
  160. getDetail () {
  161. this.spinning = true
  162. dealerDetailBySn({ sn: this.$route.params.sn }).then(res => {
  163. if (res.status == 200) {
  164. this.detail = res.data
  165. }
  166. this.spinning = false
  167. })
  168. },
  169. pageInit () {
  170. const _this = this
  171. this.getDetail()
  172. this.handleSearch()
  173. this.$nextTick(() => { // 页面渲染完成后的回调
  174. _this.setTableH()
  175. })
  176. },
  177. setTableH () {
  178. const tableSearchH = this.$refs.tableSearch.offsetHeight
  179. this.tableHeight = window.innerHeight - tableSearchH - (!this.showBtns ? 50 : 205)
  180. }
  181. },
  182. watch: {
  183. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  184. this.setTableH()
  185. }
  186. },
  187. mounted () {
  188. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  189. this.pageInit()
  190. }
  191. },
  192. activated () {
  193. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  194. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  195. this.pageInit()
  196. }
  197. },
  198. beforeRouteEnter (to, from, next) {
  199. next(vm => {})
  200. }
  201. }
  202. </script>
  203. <style lang="less" scoped>
  204. .rebateBinding-wrap{
  205. .rebateBinding-cont{
  206. margin-bottom: 6px;
  207. }
  208. }
  209. </style>