list.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <a-card size="small" :bordered="false" class="priceInquiryList-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="priceInquiryList-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="priceInquiryList-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. <a-cascader
  20. @change="changeProductType"
  21. change-on-select
  22. v-model="productType"
  23. expand-trigger="hover"
  24. :options="productTypeList"
  25. :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
  26. id="priceInquiryList-productType"
  27. placeholder="请选择产品分类"
  28. allowClear />
  29. </a-form-item>
  30. </a-col>
  31. <template v-if="advanced">
  32. <a-col :md="6" :sm="24">
  33. <a-form-item label="产品品牌">
  34. <ProductBrand id="priceInquiryList-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  35. </a-form-item>
  36. </a-col>
  37. <a-col :md="6" :sm="24">
  38. <a-form-item label="产品状态">
  39. <v-select code="PRODUCT_ONOFFLINE_STATUS" id="priceInquiryList-state" v-model="queryParam.state" allowClear placeholder="请选择状态"></v-select>
  40. </a-form-item>
  41. </a-col>
  42. </template>
  43. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  44. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="priceInquiryList-refresh">查询</a-button>
  45. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="priceInquiryList-reset">重置</a-button>
  46. <a @click="advanced=!advanced" style="margin-left: 5px">
  47. {{ advanced ? '收起' : '展开' }}
  48. <a-icon :type="advanced ? 'up' : 'down'"/>
  49. </a>
  50. </a-col>
  51. </a-row>
  52. </a-form>
  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="{ x: 1100, y: tableHeight }"
  64. :defaultLoadData="false"
  65. bordered>
  66. <!-- 产品图片 -->
  67. <template slot="imageUrl" slot-scope="text, record">
  68. <div v-if="record.productPicList && record.productPicList.length>0">
  69. <img :src="record.productPicList[0].imageUrl+'?x-oss-process=image/resize,h_30,m_lfit' || ''" width="30" height="30" class="imageUrl" @click="inited(record.productPicList)" />
  70. </div>
  71. <span v-else>--</span>
  72. </template>
  73. <!-- 产品分类 -->
  74. <template slot="productType" slot-scope="text, record">
  75. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  76. <span v-else>--</span>
  77. </template>
  78. </s-table>
  79. </a-card>
  80. </template>
  81. <script>
  82. import { STable, VSelect } from '@/components'
  83. import { productBrandQuery } from '@/api/productBrand'
  84. import { productTypeQuery } from '@/api/productType'
  85. import { productPriceList } from '@/api/product'
  86. import ProductBrand from '@/views/common/productBrand.js'
  87. export default {
  88. components: { STable, VSelect,ProductBrand },
  89. data () {
  90. return {
  91. advanced: true, // 高级搜索 展开/关闭
  92. tableHeight: 0,
  93. productType: [],
  94. queryParam: { // 查询条件
  95. code: '', // 产品编码
  96. name: '', // 产品名称
  97. productBrandSn: undefined, // 产品品牌
  98. productTypeSn1: '', // 产品一级分类
  99. productTypeSn2: '', // 产品二级分类
  100. productTypeSn3: '', // 产品三级分类
  101. state: 'ONLINE' // 产品状态
  102. },
  103. disabled: false, // 查询、重置按钮是否可操作
  104. columns: [
  105. { title: '产品编码', dataIndex: 'code', align: 'center', customRender: function (text) { return text || '--' } },
  106. { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' } },
  107. { title: '原厂编码', dataIndex: 'origCode', align: 'center', customRender: function (text) { return text || '--' } },
  108. { title: '产品状态', dataIndex: 'stateDictValue', width: 80, align: 'center', customRender: function (text) { return text || '--' } },
  109. { title: '省级价', dataIndex: 'provincePrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  110. { title: '市级价', dataIndex: 'cityPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  111. { title: '特约价', dataIndex: 'specialPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  112. { title: '终端价', dataIndex: 'terminalPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  113. { title: '车主价', dataIndex: 'carOwnersPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  114. { title: '产品图片', scopedSlots: { customRender: 'imageUrl' }, width: 80, align: 'center' }
  115. ],
  116. // 加载数据方法 必须为 Promise 对象
  117. loadData: parameter => {
  118. this.disabled = true
  119. this.spinning = true
  120. return productPriceList(Object.assign(parameter, this.queryParam)).then(res => {
  121. const data = res.data
  122. const no = (data.pageNo - 1) * data.pageSize
  123. for (var i = 0; i < data.list.length; i++) {
  124. data.list[i].no = no + i + 1
  125. }
  126. this.disabled = false
  127. this.spinning = false
  128. return data
  129. })
  130. },
  131. productBrandList: [], // 品牌下拉数据
  132. productTypeList: [] // 分类下拉数据
  133. }
  134. },
  135. methods: {
  136. inited (viewer) {
  137. if (viewer) {
  138. const imageUrl = []
  139. viewer.map(item => {
  140. imageUrl.push(item.imageUrl)
  141. })
  142. this.$viewerApi({
  143. images: imageUrl
  144. })
  145. }
  146. },
  147. // 重置
  148. resetSearchForm () {
  149. this.queryParam.code = ''
  150. this.queryParam.name = ''
  151. this.queryParam.productBrandSn = undefined
  152. this.queryParam.productTypeSn1 = ''
  153. this.queryParam.productTypeSn2 = ''
  154. this.queryParam.productTypeSn3 = ''
  155. this.queryParam.state = 'ONLINE'
  156. this.productType = []
  157. this.$refs.table.refresh(true)
  158. },
  159. // 产品分类 change
  160. changeProductType (val, opt) {
  161. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  162. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  163. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  164. },
  165. // 产品品牌 列表
  166. getProductBrand () {
  167. productBrandQuery({}).then(res => {
  168. if (res.status == 200) {
  169. this.productBrandList = res.data
  170. } else {
  171. this.productBrandList = []
  172. }
  173. })
  174. },
  175. // 产品分类 列表
  176. getProductType () {
  177. productTypeQuery({}).then(res => {
  178. if (res.status == 200) {
  179. this.productTypeList = res.data
  180. } else {
  181. this.productTypeList = []
  182. }
  183. })
  184. },
  185. pageInit () {
  186. const _this = this
  187. this.$nextTick(() => { // 页面渲染完成后的回调
  188. _this.setTableH()
  189. })
  190. this.getProductBrand()
  191. this.getProductType()
  192. },
  193. setTableH () {
  194. const tableSearchH = this.$refs.tableSearch.offsetHeight
  195. this.tableHeight = window.innerHeight - tableSearchH - 195
  196. }
  197. },
  198. watch: {
  199. advanced (newValue, oldValue) {
  200. const _this = this
  201. setTimeout(() => {
  202. _this.setTableH()
  203. }, 400)
  204. }
  205. },
  206. mounted () {
  207. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  208. this.pageInit()
  209. this.resetSearchForm()
  210. }
  211. },
  212. activated () {
  213. // 如果是新页签打开,则重置当前页面
  214. if (this.$store.state.app.isNewTab) {
  215. this.pageInit()
  216. this.resetSearchForm()
  217. }
  218. },
  219. beforeRouteEnter (to, from, next) {
  220. next(vm => {})
  221. }
  222. }
  223. </script>