list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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 { dealerProductBrandQuery } from '@/api/dealerProductBrand'
  113. import { productTypeQuery } from '@/api/productType'
  114. import { productList, getCurrentDealer } from '@/api/product'
  115. import { STable, VSelect } from '@/components'
  116. import { downloadExcel } from '@/libs/JGPrint.js'
  117. export default {
  118. name: 'ProductJgList',
  119. components: { STable, VSelect },
  120. data () {
  121. return {
  122. advanced: true, // 高级搜索 展开/关闭
  123. tableHeight: 0,
  124. productType: [],
  125. queryParam: { // 查询条件
  126. code: '', // 产品编码
  127. name: '', // 产品名称
  128. origCode: '', // 原厂编码
  129. sysFlag: '1',
  130. productBrandSn: undefined, // 产品品牌
  131. productTypeSn1: '', // 产品一级分类
  132. productTypeSn2: '', // 产品二级分类
  133. productTypeSn3: '', // 产品三级分类
  134. onlineFalg: '1'
  135. },
  136. disabled: false, // 查询、重置按钮是否可操作
  137. exportLoading: false, // 导出loading
  138. dateFormat: 'YYYY-MM-DD',
  139. columns: [],
  140. // 加载数据方法 必须为 Promise 对象
  141. loadData: parameter => {
  142. this.disabled = true
  143. this.spinning = true
  144. return productList(Object.assign(parameter, this.queryParam)).then(res => {
  145. let data
  146. if (res.status == 200) {
  147. data = res.data
  148. const no = (data.pageNo - 1) * data.pageSize
  149. for (var i = 0; i < data.list.length; i++) {
  150. data.list[i].no = no + i + 1
  151. }
  152. this.disabled = false
  153. }
  154. this.spinning = false
  155. return data
  156. })
  157. },
  158. openModal: false, // 查看客户详情 弹框
  159. itemId: '', // 当前产品id
  160. productBrandList: [], // 品牌下拉数据
  161. productTypeList: [] // 分类下拉数据
  162. }
  163. },
  164. methods: {
  165. inited (viewer) {
  166. if (viewer) {
  167. const imageUrl = []
  168. viewer.map(item => {
  169. imageUrl.push(item.imageUrl)
  170. })
  171. this.$viewerApi({
  172. images: imageUrl
  173. })
  174. }
  175. },
  176. // 详情
  177. handleDetail (row) {
  178. this.$router.push({ name: 'viewProduct', params: { sn: row.productSn } })
  179. },
  180. // 重置
  181. resetSearchForm () {
  182. this.queryParam.code = ''
  183. this.queryParam.name = ''
  184. this.queryParam.origCode = ''
  185. this.queryParam.productBrandSn = undefined
  186. this.queryParam.productTypeSn1 = ''
  187. this.queryParam.productTypeSn2 = ''
  188. this.queryParam.productTypeSn3 = ''
  189. this.queryParam.onlineFalg = '1'
  190. this.productType = []
  191. this.$refs.table.refresh(true)
  192. },
  193. // 设置表头
  194. getColumns () {
  195. this.columns = [
  196. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  197. { title: '产品编码', dataIndex: 'code', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  198. { title: '产品名称', dataIndex: 'name', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  199. { title: '原厂编码', dataIndex: 'origCode', width: '17%', align: 'center', customRender: function (text) { return (!text || text == ' ') ? '--' : text } }
  200. // { title: '产品品牌', dataIndex: 'productBrandName', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  201. // { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: 120, align: 'center' }
  202. ]
  203. const cArr = [
  204. { title: '终端价', dataIndex: 'terminalPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  205. { title: '车主价', dataIndex: 'carOwnersPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  206. { title: '产品图片', scopedSlots: { customRender: 'imageUrl' }, width: '6%', align: 'center' },
  207. // { title: '创建时间', dataIndex: 'createDate', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  208. // { title: '状态', dataIndex: 'onlineFalgDictValue', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  209. { title: '操作', scopedSlots: { customRender: 'action' }, width: '7%', align: 'center' }
  210. ]
  211. getCurrentDealer().then(res => {
  212. if (res.status == 200) {
  213. if (res.data.dealerLevel && res.data.dealerLevel == 'PROVINCE') { // 省级
  214. this.columns.push(
  215. { title: '省级价', dataIndex: 'provincePrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  216. { title: '市级价', dataIndex: 'cityPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  217. )
  218. } else if (res.data.dealerLevel && res.data.dealerLevel == 'CITY') { // 市级
  219. this.columns.push(
  220. { title: '市级价', dataIndex: 'cityPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  221. )
  222. }
  223. if (res.data.isShowSpecialPrice && res.data.isShowSpecialPrice == '1') { // 是否展示特约价
  224. this.columns.push({ title: '特约价', dataIndex: 'specialPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  225. }
  226. this.columns = [...this.columns, ...cArr]
  227. }
  228. })
  229. },
  230. filterOption (input, option) {
  231. return (
  232. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  233. )
  234. },
  235. // 产品分类 change
  236. changeProductType (val, opt) {
  237. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  238. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  239. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  240. },
  241. // 导出
  242. handleExport () {
  243. this.exportLoading = true
  244. // dealerProductExport(this.queryParam).then(res => {
  245. // this.exportLoading = false
  246. // downloadExcel(res, '箭冠产品列表')
  247. // })
  248. },
  249. // 产品品牌 列表
  250. getProductBrand () {
  251. dealerProductBrandQuery({ 'sysFlag': '1' }).then(res => {
  252. if (res.status == 200) {
  253. this.productBrandList = res.data
  254. } else {
  255. this.productBrandList = []
  256. }
  257. })
  258. },
  259. // 产品分类 列表
  260. getProductType () {
  261. productTypeQuery({}).then(res => {
  262. if (res.status == 200) {
  263. this.productTypeList = res.data
  264. } else {
  265. this.productTypeList = []
  266. }
  267. })
  268. },
  269. pageInit () {
  270. const _this = this
  271. this.$nextTick(() => { // 页面渲染完成后的回调
  272. _this.setTableH()
  273. })
  274. this.getColumns()
  275. this.getProductBrand()
  276. this.getProductType()
  277. },
  278. setTableH () {
  279. const tableSearchH = this.$refs.tableSearch.offsetHeight
  280. this.tableHeight = window.innerHeight - tableSearchH - 195
  281. }
  282. },
  283. watch: {
  284. advanced (newValue, oldValue) {
  285. const _this = this
  286. this.$nextTick(() => { // 页面渲染完成后的回调
  287. _this.setTableH()
  288. })
  289. },
  290. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  291. this.setTableH()
  292. }
  293. },
  294. mounted () {
  295. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  296. this.pageInit()
  297. this.resetSearchForm()
  298. }
  299. },
  300. activated () {
  301. // 如果是新页签打开,则重置当前页面
  302. if (this.$store.state.app.isNewTab) {
  303. this.pageInit()
  304. this.resetSearchForm()
  305. }
  306. },
  307. beforeRouteEnter (to, from, next) {
  308. next(vm => {})
  309. }
  310. }
  311. </script>