list.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <a-card size="small" :bordered="false" class="productPricingList-wrap">
  3. <!-- 搜索条件 -->
  4. <div ref="tableSearch" class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="产品编码">
  9. <a-input id="productPricingList-code" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="产品名称">
  14. <a-input id="productPricingList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="产品品牌">
  19. <ProductBrand id="productPricingList-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  20. </a-form-item>
  21. </a-col>
  22. <template v-if="advanced">
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="产品分类">
  25. <ProductType id="productPricingList-productType" @change="changeProductType" v-model="productType"></ProductType>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="原厂编码">
  30. <a-input id="productPricingList-origCode" v-model.trim="queryParam.origCode" allowClear placeholder="请输入原厂编码"/>
  31. </a-form-item>
  32. </a-col>
  33. </template>
  34. <a-col :md="6" :sm="24">
  35. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productPricingList-refresh">查询</a-button>
  36. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productPricingList-reset">重置</a-button>
  37. <a @click="advanced=!advanced" style="margin-left: 5px">
  38. {{ advanced ? '收起' : '展开' }}
  39. <a-icon :type="advanced ? 'up' : 'down'"/>
  40. </a>
  41. </a-col>
  42. </a-row>
  43. </a-form>
  44. </div>
  45. <!-- 价格 -->
  46. <div style="margin-bottom: 10px;">
  47. <a-checkbox v-model="isCostPrice"><span style="display: inline-block;">成本价</span></a-checkbox>
  48. <!-- 特约加盟商不可见市级价 -->
  49. <a-checkbox v-model="isCityPrice" v-if="dealerData && dealerData.dealerLevel != 'SPECIAL'"><span style="display: inline-block;">市级价</span></a-checkbox>
  50. <!-- 是否展示特约价 -->
  51. <a-checkbox v-model="isSpecialPrice" v-if="dealerData && dealerData.isShowSpecialPrice == '1'"><span style="display: inline-block;">特约价</span></a-checkbox>
  52. <a-checkbox v-model="isTerminalPrice"><span style="display: inline-block;">终端会员价</span></a-checkbox>
  53. </div>
  54. <!-- 列表 -->
  55. <s-table
  56. class="sTable fixPagination"
  57. ref="table"
  58. :style="{ height: tableHeight+84.5+'px' }"
  59. size="small"
  60. :rowKey="(record) => record.id"
  61. :columns="columns"
  62. :data="loadData"
  63. :scroll="{ y: tableHeight }"
  64. :defaultLoadData="false"
  65. bordered>
  66. </s-table>
  67. </a-card>
  68. </template>
  69. <script>
  70. import { STable, VSelect } from '@/components'
  71. import ProductType from '../../common/productType.js'
  72. import ProductBrand from '../../common/productBrand.js'
  73. import { getCurrentDealer } from '@/api/product'
  74. import { dealerProductPriceList } from '@/api/dealerProduct'
  75. export default {
  76. components: { STable, VSelect, ProductType, ProductBrand },
  77. data () {
  78. return {
  79. tableHeight: 0,
  80. advanced: true, // 高级搜索 展开/关闭
  81. queryParam: { // 查询条件
  82. name: '',
  83. code: '',
  84. origCode: '',
  85. productBrandSn: undefined,
  86. productTypeSn1: '',
  87. productTypeSn2: '',
  88. productTypeSn3: ''
  89. },
  90. productType: [],
  91. disabled: false, // 查询、重置按钮是否可操作
  92. // 加载数据方法 必须为 Promise 对象
  93. loadData: parameter => {
  94. this.disabled = true
  95. this.spinning = true
  96. return dealerProductPriceList(Object.assign(parameter, this.queryParam)).then(res => {
  97. let data
  98. if (res.status == 200) {
  99. data = res.data
  100. const no = (data.pageNo - 1) * data.pageSize
  101. for (var i = 0; i < data.list.length; i++) {
  102. data.list[i].no = no + i + 1
  103. }
  104. this.disabled = false
  105. }
  106. this.spinning = false
  107. return data
  108. })
  109. },
  110. isCostPrice: false,
  111. isCityPrice: false,
  112. isSpecialPrice: false,
  113. isTerminalPrice: false,
  114. dealerData: null
  115. }
  116. },
  117. computed: {
  118. columns () {
  119. const arr = [
  120. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  121. { title: '产品编码', dataIndex: 'code', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
  122. { title: '产品名称', dataIndex: 'name', width: '19%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  123. { title: '原厂编码', dataIndex: 'origCode', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  124. { title: '品牌', dataIndex: 'productBrandName', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
  125. { title: '库存数量', dataIndex: 'stockQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  126. // { title: '成本价', dataIndex: 'offerCost', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  127. // { title: '市级价', dataIndex: 'cityPrice', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  128. // { title: '特约价', dataIndex: 'specialPrice', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  129. // { title: '终端会员价', dataIndex: 'terminalPrice', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  130. { title: '车主价', dataIndex: 'carOwnersPrice', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  131. ]
  132. if (this.isCostPrice) {
  133. arr.splice(6, 0, { title: '成本价', dataIndex: 'offerCost', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  134. }
  135. if (this.isCityPrice) {
  136. const ind = this.isCostPrice ? 7 : 6
  137. arr.splice(ind, 0, { title: '市级价', dataIndex: 'cityPrice', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  138. }
  139. if (this.isSpecialPrice) {
  140. let ind = 0
  141. if (this.isCostPrice && this.isCityPrice) {
  142. ind = 8
  143. } else if ((!this.isCostPrice && this.isCityPrice) || (this.isCostPrice && !this.isCityPrice)) {
  144. ind = 7
  145. } else if (!this.isCostPrice && !this.isCityPrice) {
  146. ind = 6
  147. }
  148. arr.splice(ind, 0, { title: '特约价', dataIndex: 'specialPrice', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  149. }
  150. if (this.isTerminalPrice) {
  151. arr.splice(arr.length - 1, 0, { title: '终端会员价', dataIndex: 'terminalPrice', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  152. }
  153. return arr
  154. }
  155. },
  156. methods: {
  157. // 重置
  158. resetSearchForm () {
  159. this.queryParam.name = ''
  160. this.queryParam.code = ''
  161. this.queryParam.origCode = ''
  162. this.queryParam.productBrandSn = undefined
  163. this.queryParam.productTypeSn1 = ''
  164. this.queryParam.productTypeSn2 = ''
  165. this.queryParam.productTypeSn3 = ''
  166. this.productType = []
  167. this.$refs.table.refresh(true)
  168. },
  169. // 产品分类 change
  170. changeProductType (val, opt) {
  171. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  172. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  173. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  174. },
  175. pageInit () {
  176. const _this = this
  177. this.$nextTick(() => { // 页面渲染完成后的回调
  178. _this.setTableH()
  179. })
  180. // 获取当前登录用户经销商等级
  181. getCurrentDealer().then(res => {
  182. if (res.status == 200) {
  183. this.dealerData = res.data
  184. } else {
  185. this.dealerData = null
  186. }
  187. })
  188. },
  189. setTableH () {
  190. const tableSearchH = this.$refs.tableSearch.offsetHeight
  191. this.tableHeight = window.innerHeight - tableSearchH - 230
  192. }
  193. },
  194. watch: {
  195. advanced (newValue, oldValue) {
  196. const _this = this
  197. this.$nextTick(() => { // 页面渲染完成后的回调
  198. _this.setTableH()
  199. })
  200. },
  201. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  202. this.setTableH()
  203. }
  204. },
  205. mounted () {
  206. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  207. this.pageInit()
  208. this.resetSearchForm()
  209. }
  210. },
  211. activated () {
  212. // 如果是新页签打开,则重置当前页面
  213. if (this.$store.state.app.isNewTab) {
  214. this.pageInit()
  215. this.resetSearchForm()
  216. }
  217. },
  218. beforeRouteEnter (to, from, next) {
  219. next(vm => {})
  220. }
  221. }
  222. </script>