list.vue 11 KB

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