list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <a-card size="small" :bordered="false" class="productInfoList-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="productInfoList-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="productInfoList-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-input id="productInfoList-origCode" v-model.trim="queryParam.origCode" allowClear placeholder="请输入原厂编码"/>
  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. <a-select
  26. placeholder="请选择产品品牌"
  27. id="productInfoList-productBrandSn"
  28. allowClear
  29. v-model="queryParam.productBrandSn"
  30. :showSearch="true"
  31. option-filter-prop="children"
  32. :dropdownMatchSelectWidth="false"
  33. :filter-option="filterOption">
  34. <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
  35. </a-select>
  36. </a-form-item>
  37. </a-col>
  38. <!-- <a-col :md="6" :sm="24">
  39. <a-form-item label="产品分类">
  40. <a-cascader
  41. @change="changeProductType"
  42. change-on-select
  43. v-model="productType"
  44. expand-trigger="hover"
  45. :options="productTypeList"
  46. :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
  47. id="productInfoList-productType"
  48. placeholder="请选择产品分类"
  49. allowClear />
  50. </a-form-item>
  51. </a-col> -->
  52. <!-- <a-col :md="6" :sm="24">
  53. <a-form-item label="状态">
  54. <v-select code="ONLINE_FLAG" id="productInfoList-onlineFalg" v-model="queryParam.onlineFalg" allowClear placeholder="请选择状态"></v-select>
  55. </a-form-item>
  56. </a-col> -->
  57. </template>
  58. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  59. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  60. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productInfoList-reset">重置</a-button>
  61. <!-- <a-button
  62. style="margin: 0 0 18px 8px"
  63. type="danger"
  64. @click="handleExport"
  65. :disabled="disabled"
  66. :loading="exportLoading"
  67. id="inventoryQueryList-export">导出</a-button> -->
  68. <a @click="advanced=!advanced" style="margin-left: 5px">
  69. {{ advanced ? '收起' : '展开' }}
  70. <a-icon :type="advanced ? 'up' : 'down'"/>
  71. </a>
  72. </a-col>
  73. </a-row>
  74. </a-form>
  75. </div>
  76. <!-- 列表 -->
  77. <s-table
  78. class="sTable fixPagination"
  79. ref="table"
  80. :style="{ height: tableHeight+84.5+'px' }"
  81. size="small"
  82. :rowKey="(record) => record.id"
  83. :columns="columns"
  84. :data="loadData"
  85. :scroll="{ y: tableHeight }"
  86. :defaultLoadData="false"
  87. bordered>
  88. <!-- 产品图片 -->
  89. <template slot="imageUrl" slot-scope="text, record">
  90. <div v-if="record.productPicList && record.productPicList.length>0">
  91. <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)" />
  92. </div>
  93. <span v-else>--</span>
  94. </template>
  95. <!-- 产品分类 -->
  96. <template slot="productType" slot-scope="text, record">
  97. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  98. <span v-else>--</span>
  99. </template>
  100. <template slot="action" slot-scope="text, record">
  101. <a-button
  102. size="small"
  103. type="link"
  104. class="button-success"
  105. @click="handleDetail(record)"
  106. id="productInfoList-detail-btn">详情</a-button>
  107. </template>
  108. </s-table>
  109. </a-card>
  110. </template>
  111. <script>
  112. import moment from 'moment'
  113. import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
  114. import { productTypeQuery } from '@/api/productType'
  115. import { productList, getCurrentDealer } from '@/api/product'
  116. import { STable, VSelect } from '@/components'
  117. import { downloadExcel } from '@/libs/JGPrint.js'
  118. export default {
  119. name: 'ProductJgList',
  120. components: { STable, VSelect },
  121. data () {
  122. return {
  123. advanced: true, // 高级搜索 展开/关闭
  124. tableHeight: 0,
  125. productType: [],
  126. queryParam: { // 查询条件
  127. code: '', // 产品编码
  128. name: '', // 产品名称
  129. origCode: '', // 原厂编码
  130. sysFlag: '1',
  131. productBrandSn: undefined, // 产品品牌
  132. productTypeSn1: '', // 产品一级分类
  133. productTypeSn2: '', // 产品二级分类
  134. productTypeSn3: '', // 产品三级分类
  135. onlineFalg: '1'
  136. },
  137. disabled: false, // 查询、重置按钮是否可操作
  138. exportLoading: false, // 导出loading
  139. dateFormat: 'YYYY-MM-DD',
  140. columns: [],
  141. // 加载数据方法 必须为 Promise 对象
  142. loadData: parameter => {
  143. this.disabled = true
  144. this.spinning = true
  145. return productList(Object.assign(parameter, this.queryParam)).then(res => {
  146. const data = res.data
  147. const no = (data.pageNo - 1) * data.pageSize
  148. for (var i = 0; i < data.list.length; i++) {
  149. data.list[i].no = no + i + 1
  150. }
  151. this.disabled = false
  152. this.spinning = false
  153. return data
  154. })
  155. },
  156. openModal: false, // 查看客户详情 弹框
  157. itemId: '', // 当前产品id
  158. productBrandList: [], // 品牌下拉数据
  159. productTypeList: [] // 分类下拉数据
  160. }
  161. },
  162. methods: {
  163. inited (viewer) {
  164. if (viewer) {
  165. const imageUrl = []
  166. viewer.map(item => {
  167. imageUrl.push(item.imageUrl)
  168. })
  169. this.$viewerApi({
  170. images: imageUrl
  171. })
  172. }
  173. },
  174. // 详情
  175. handleDetail (row) {
  176. this.$router.push({ name: 'viewProduct', params: { sn: row.productSn } })
  177. },
  178. // 重置
  179. resetSearchForm () {
  180. this.queryParam.code = ''
  181. this.queryParam.name = ''
  182. this.queryParam.origCode = ''
  183. this.queryParam.productBrandSn = undefined
  184. this.queryParam.productTypeSn1 = ''
  185. this.queryParam.productTypeSn2 = ''
  186. this.queryParam.productTypeSn3 = ''
  187. this.queryParam.onlineFalg = '1'
  188. this.productType = []
  189. this.$refs.table.refresh(true)
  190. },
  191. // 设置表头
  192. getColumns () {
  193. this.columns = [
  194. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  195. { title: '产品编码', dataIndex: 'code', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  196. { title: '产品名称', dataIndex: 'name', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  197. { title: '原厂编码', dataIndex: 'origCode', width: '17%', align: 'center', customRender: function (text) { return (!text || text == ' ') ? '--' : text } }
  198. // { title: '产品品牌', dataIndex: 'productBrandName', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  199. // { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: 120, align: 'center' }
  200. ]
  201. const cArr = [
  202. { title: '终端价', dataIndex: 'terminalPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  203. { title: '车主价', dataIndex: 'carOwnersPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  204. { title: '产品图片', scopedSlots: { customRender: 'imageUrl' }, width: '6%', align: 'center' },
  205. // { title: '创建时间', dataIndex: 'createDate', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  206. // { title: '状态', dataIndex: 'onlineFalgDictValue', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  207. { title: '操作', scopedSlots: { customRender: 'action' }, width: '7%', align: 'center' }
  208. ]
  209. getCurrentDealer().then(res => {
  210. if (res.status == 200) {
  211. if (res.data.dealerLevel && res.data.dealerLevel == 'PROVINCE') { // 省级
  212. this.columns.push(
  213. { title: '省级价', dataIndex: 'provincePrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  214. { title: '市级价', dataIndex: 'cityPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  215. )
  216. } else if (res.data.dealerLevel && res.data.dealerLevel == 'CITY') { // 市级
  217. this.columns.push(
  218. { title: '市级价', dataIndex: 'cityPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  219. )
  220. }
  221. if (res.data.isShowSpecialPrice && res.data.isShowSpecialPrice == '1') { // 是否展示特约价
  222. this.columns.push({ title: '特约价', dataIndex: 'specialPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  223. }
  224. this.columns = [...this.columns, ...cArr]
  225. }
  226. })
  227. },
  228. filterOption (input, option) {
  229. return (
  230. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  231. )
  232. },
  233. // 产品分类 change
  234. changeProductType (val, opt) {
  235. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  236. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  237. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  238. },
  239. // 导出
  240. handleExport () {
  241. this.exportLoading = true
  242. // dealerProductExport(this.queryParam).then(res => {
  243. // this.exportLoading = false
  244. // const fileName = '箭冠产品列表' + moment().format('YYYYMMDDHHmmss')
  245. // downloadExcel(res, fileName)
  246. // })
  247. },
  248. // 产品品牌 列表
  249. getProductBrand () {
  250. dealerProductBrandQuery({ 'sysFlag': '1' }).then(res => {
  251. if (res.status == 200) {
  252. this.productBrandList = res.data
  253. } else {
  254. this.productBrandList = []
  255. }
  256. })
  257. },
  258. // 产品分类 列表
  259. getProductType () {
  260. productTypeQuery({}).then(res => {
  261. if (res.status == 200) {
  262. this.productTypeList = res.data
  263. } else {
  264. this.productTypeList = []
  265. }
  266. })
  267. },
  268. pageInit () {
  269. const _this = this
  270. this.$nextTick(() => { // 页面渲染完成后的回调
  271. _this.setTableH()
  272. })
  273. this.getColumns()
  274. this.getProductBrand()
  275. this.getProductType()
  276. },
  277. setTableH () {
  278. const tableSearchH = this.$refs.tableSearch.offsetHeight
  279. this.tableHeight = window.innerHeight - tableSearchH - 195
  280. }
  281. },
  282. watch: {
  283. advanced (newValue, oldValue) {
  284. const _this = this
  285. setTimeout(() => {
  286. _this.setTableH()
  287. }, 400)
  288. },
  289. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  290. this.setTableH()
  291. }
  292. },
  293. mounted () {
  294. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  295. this.pageInit()
  296. this.resetSearchForm()
  297. }
  298. },
  299. activated () {
  300. // 如果是新页签打开,则重置当前页面
  301. if (this.$store.state.app.isNewTab) {
  302. this.pageInit()
  303. this.resetSearchForm()
  304. }
  305. },
  306. beforeRouteEnter (to, from, next) {
  307. next(vm => {})
  308. }
  309. }
  310. </script>