list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form-model
  7. ref="ruleForm"
  8. class="form-model-con"
  9. layout="inline"
  10. :rules="rules"
  11. :model="queryParam"
  12. @keyup.enter.native="$refs.table.refresh(true)" >
  13. <a-row :gutter="15">
  14. <a-col :md="6" :sm="24">
  15. <a-form-model-item label="车架号(VIN)" prop="vinCode">
  16. <a-input id="priceInquiryList-vinCode" v-model.trim="queryParam.vinCode" allowClear placeholder="请输入车架号(VIN)">
  17. <a-icon @click="uploadFun" :type="vinLoading?'loading':'camera'" slot="addonAfter" :style="{ fontSize: '18px', verticalAlign: 'bottom' }" />
  18. </a-input>
  19. <input type="file" id="filed" accept="image/jpeg,image/png" hidden="" @change="filePreview">
  20. </a-form-model-item>
  21. </a-col>
  22. <a-col :md="6" :sm="24">
  23. <a-form-model-item label="产品编码">
  24. <a-input id="priceInquiryList-code" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
  25. </a-form-model-item>
  26. </a-col>
  27. <a-col :md="6" :sm="24">
  28. <a-form-model-item label="产品名称">
  29. <a-input id="priceInquiryList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
  30. </a-form-model-item>
  31. </a-col>
  32. <template v-if="advanced">
  33. <a-col :md="6" :sm="24">
  34. <a-form-item label="产品分类">
  35. <ProductType v-model="productType" id="priceInquiryList-productType" @change="changeProductType" placeholder="请选择产品分类"></ProductType>
  36. </a-form-item>
  37. </a-col>
  38. <a-col :md="6" :sm="24">
  39. <a-form-model-item label="产品品牌">
  40. <ProductBrand id="priceInquiryList-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  41. </a-form-model-item>
  42. </a-col>
  43. <a-col :md="6" :sm="24">
  44. <a-form-model-item label="产品状态">
  45. <v-select code="PRODUCT_ONOFFLINE_STATUS" id="priceInquiryList-state" v-model="queryParam.state" allowClear placeholder="请选择状态"></v-select>
  46. </a-form-model-item>
  47. </a-col>
  48. </template>
  49. <a-col :md="6" :sm="24" style="text-align:center;">
  50. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="priceInquiryList-refresh">查询</a-button>
  51. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="priceInquiryList-reset">重置</a-button>
  52. <a @click="advanced=!advanced" style="margin-left: 5px">
  53. {{ advanced ? '收起' : '展开' }}
  54. <a-icon :type="advanced ? 'up' : 'down'"/>
  55. </a>
  56. </a-col>
  57. </a-row>
  58. </a-form-model>
  59. </div>
  60. </a-card>
  61. <a-card size="small" :bordered="false" class="priceInquiryList-wrap" style="margin-top:10px;">
  62. <div ref="vinInfo" v-if="vinInfoData">
  63. <a-alert type="error" style="margin-bottom: 10px;" v-if="vinInfoData&&!vinInfoData.carInfo">
  64. <template slot="message"><a-icon type="exclamation-circle" theme="filled" :style="{ color: '#E70012', fontSize: '15px', verticalAlign: 'sub', marginRight: '3px' }" />抱歉!暂未找到匹配VIN码的车型!</template>
  65. </a-alert>
  66. <a-alert type="warning" style="margin-bottom: 10px;cursor: pointer;" v-if="vinInfoData&&vinInfoData.carInfo" @click="openCarInfoModal=true">
  67. <template slot="message">
  68. <div style="display: flex;justify-content: space-between;align-items: center;" @click="openCarInfoModal=true">
  69. <div>
  70. <img :src="vinInfoData.carInfo && vinInfoData.carInfo.icon?(vinInfoData.carInfo.icon+'?x-oss-process=image/resize,h_30,m_lfit'):defImg" width="30" height="30" class="imageUrl" style="border-radius: 50%;vertical-align: middle;margin-right: 3px;" />
  71. <span style="vertical-align: middle;">{{ vinInfoData.carInfo.brandName }} {{ vinInfoData.carInfo.modelName }} {{ vinInfoData.carInfo.displacement }} {{ vinInfoData.carInfo.modelYear+'年' }}</span>
  72. </div>
  73. <div style="color: #f90;">
  74. <span>查看更多</span> >
  75. </div>
  76. </div>
  77. </template>
  78. </a-alert>
  79. </div>
  80. <!-- 列表 -->
  81. <s-table
  82. class="sTable"
  83. ref="table"
  84. size="small"
  85. :rowKey="(record) => record.id"
  86. :columns="columns"
  87. :data="loadData"
  88. :pageSize="15"
  89. :defaultLoadData="false"
  90. >
  91. <!-- 产品分类 -->
  92. <template slot="productType" slot-scope="text, record">
  93. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  94. <span v-else>--</span>
  95. </template>
  96. <!-- 产品编码 可点击查看详情 -->
  97. <template slot="detail" slot-scope="text, record">
  98. <div style="display: flex;">
  99. <div style="width: 60px;height: 60px;margin:6px 10px 6px 6px;">
  100. <img
  101. :src="record.productPicList && record.productPicList.length>0 ? record.productPicList[0].imageUrl+'?x-oss-process=image/resize,h_60,m_lfit' : defImg"
  102. width="60"
  103. height="60"
  104. class="imageUrl"
  105. @click="inited(record.productPicList)" />
  106. </div>
  107. <div style="flex-grow: 1;padding:6px;">
  108. <h3>{{ record.name }}</h3>
  109. <h4>产品编码:<span class="link-bule" @click="handleDetail(record)">{{ record.code }}</span></h4>
  110. <h4>原厂编码:<span>{{ record.origCode||'--' }}</span></h4>
  111. <h4>产品状态:<span>{{ record.stateDictValue }}</span></h4>
  112. <div style="display: flex;flex-wrap: wrap;">
  113. <div style="width:33%">省级价:<span style="color:red" v-if="$hasPermissions('M_priceInquiryList_provincePrice')">{{ toThousands(record.provincePrice) }}</span></div>
  114. <div style="width:33%">市级价:<span style="color:red" v-if="$hasPermissions('M_priceInquiryList_cityPrice')">{{ toThousands(record.cityPrice) }}</span></div>
  115. <div style="width:33%">特约价:<span style="color:red" v-if="$hasPermissions('M_priceInquiryList_specialPrice')">{{ toThousands(record.specialPrice) }}</span></div>
  116. <div style="width:33%">终端价:<span style="color:red" >{{ toThousands(record.terminalPrice) }}</span></div>
  117. <div style="width:33%">车主价:<span style="color:red" >{{ toThousands(record.carOwnersPrice) }}</span></div>
  118. </div>
  119. </div>
  120. </div>
  121. </template>
  122. </s-table>
  123. <!-- 查看车辆信息 -->
  124. <car-info-modal v-drag ref="carInfoModal" :openModal="openCarInfoModal" :infoData="vinInfoData&&vinInfoData.carInfo" @close="openCarInfoModal=false" />
  125. </a-card>
  126. </div>
  127. </template>
  128. <script>
  129. import { commonMixin } from '@/utils/mixin'
  130. import { STable, VSelect } from '@/components'
  131. import carInfoModal from './carInfoModal.vue'
  132. import ProductType from '@/views/common/productType.js'
  133. import ProductBrand from '@/views/common/productBrand.js'
  134. import { productPriceList } from '@/api/product'
  135. import { supperCodeByVin, vinCodeParse } from '@/api/sales'
  136. import defImg from '@/assets/def_img@2x.png'
  137. export default {
  138. name: 'PriceInquiryList',
  139. mixins: [commonMixin],
  140. components: { STable, VSelect, ProductBrand, carInfoModal, ProductType },
  141. data () {
  142. return {
  143. advanced: false, // 高级搜索 展开/关闭
  144. vinLoading: false,
  145. tableHeight: 0,
  146. productType: [],
  147. defImg,
  148. queryParam: { // 查询条件
  149. code: '', // 产品编码
  150. name: '', // 产品名称
  151. vinCode: '',
  152. codeList: undefined, // 车架号
  153. productBrandSn: undefined, // 产品品牌
  154. productTypeSn1: '', // 产品一级分类
  155. productTypeSn2: '', // 产品二级分类
  156. productTypeSn3: '', // 产品三级分类
  157. state: 'ONLINE' // 产品状态
  158. },
  159. rules: {
  160. vinCode: [ { len: 17, message: '请输入正确的车架号(VIN)', trigger: 'change' } ]
  161. },
  162. disabled: false, // 查询、重置按钮是否可操作
  163. // 加载数据方法 必须为 Promise 对象
  164. loadData: parameter => {
  165. const _this = this
  166. const params = Object.assign(parameter, _this.queryParam)
  167. if (_this.queryParam.vinCode && _this.queryParam.vinCode.length == 17 && !this.onlyList) { // 输入vin,查出vin码信息后请求列表数据
  168. _this.disabled = true
  169. return supperCodeByVin({ vin: _this.queryParam.vinCode }).then(res => {
  170. if (res.status == 200) {
  171. _this.vinInfoData = res.data
  172. params.codeList = res.data.partCodeList || []
  173. return _this.getList(params)
  174. } else {
  175. _this.vinInfoData = null
  176. _this.$refs.table.localLoading = false
  177. _this.$refs.table.clearTable()
  178. }
  179. })
  180. } else if (_this.queryParam.vinCode && _this.queryParam.vinCode.length < 17 && !this.onlyList) { // 输入vin,但vin码不符合标准,不查vin码信息,不请求列表数据
  181. _this.$refs.table.localLoading = false
  182. _this.$refs.table.clearTable()
  183. } else if (this.onlyList) {
  184. _this.disabled = true
  185. if (_this.queryParam.vinCode && _this.vinInfoData) {
  186. return _this.getList(Object.assign(params, { codeList: _this.vinInfoData.partCodeList }))
  187. } else {
  188. return _this.getList(params)
  189. }
  190. } else { // 未输入vin码信息,只查列表数据
  191. _this.disabled = true
  192. return _this.getList(params)
  193. }
  194. },
  195. vinInfoData: null,
  196. openCarInfoModal: false,
  197. onlyList: false
  198. }
  199. },
  200. computed: {
  201. columns () {
  202. const arr = [
  203. { title: '产品列表', scopedSlots: { customRender: 'detail' }, width: '100%' }
  204. ]
  205. return arr
  206. }
  207. },
  208. methods: {
  209. // 详情
  210. handleDetail (row) {
  211. this.itemId = row.productSn
  212. this.$router.push({ name: 'viewProduct', params: { sn: row.productSn } })
  213. },
  214. getList (params) {
  215. const _this = this
  216. return productPriceList(params).then(res => {
  217. let data
  218. this.onlyList = false
  219. if (res.status == 200) {
  220. data = res.data
  221. data.list = data.list.filter(item => item != null)
  222. const no = (data.pageNo - 1) * data.pageSize
  223. for (var i = 0; i < data.list.length; i++) {
  224. data.list[i].no = no + i + 1
  225. }
  226. if (!params.vinCode) {
  227. _this.vinInfoData = null
  228. }
  229. } else {
  230. data = {
  231. list: [],
  232. pageNo: 1,
  233. pageSize: 10
  234. }
  235. }
  236. _this.disabled = false
  237. return data
  238. })
  239. },
  240. inited (viewer) {
  241. if (viewer) {
  242. const imageUrl = []
  243. viewer.map(item => {
  244. imageUrl.push(item.imageUrl)
  245. })
  246. this.$viewerApi({
  247. images: imageUrl
  248. })
  249. }
  250. },
  251. // 重置
  252. resetSearchForm () {
  253. this.queryParam.code = ''
  254. this.queryParam.name = ''
  255. this.queryParam.productBrandSn = undefined
  256. this.queryParam.productTypeSn1 = ''
  257. this.queryParam.productTypeSn2 = ''
  258. this.queryParam.productTypeSn3 = ''
  259. this.queryParam.state = 'ONLINE'
  260. this.queryParam.codeList = undefined
  261. this.productType = []
  262. this.$refs.ruleForm.resetFields()
  263. this.$refs.table.refresh(true)
  264. this.vinInfoData = null
  265. },
  266. uploadFun () {
  267. document.getElementById('filed').click()
  268. },
  269. filePreview (e) {
  270. const _this = this
  271. var files = e.target.files[0]
  272. const formData = new FormData()
  273. formData.append('savePathType', 'local')
  274. formData.append('file', files)
  275. this.vinLoading = true
  276. vinCodeParse(formData).then(res => {
  277. if (res.type == 'application/json') {
  278. var reader = new FileReader()
  279. reader.addEventListener('loadend', function () {
  280. const obj = JSON.parse(reader.result)
  281. if (obj.status == 200) {
  282. _this.queryParam.vinCode = obj.data || ''
  283. // 移除表单项的校验结果
  284. _this.$refs.ruleForm.clearValidate('vinCode')
  285. } else {
  286. _this.$notification.error({
  287. message: '提示',
  288. description: obj.message
  289. })
  290. }
  291. _this.vinLoading = false
  292. document.getElementById('filed').value = ''
  293. })
  294. reader.readAsText(res)
  295. } else {
  296. _this.vinLoading = false
  297. }
  298. })
  299. },
  300. // 产品分类 change
  301. changeProductType (val, opt) {
  302. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  303. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  304. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  305. },
  306. pageInit () {
  307. const _this = this
  308. this.$nextTick(() => { // 页面渲染完成后的回调
  309. _this.setTableH()
  310. })
  311. },
  312. setTableH () {
  313. const tableSearchH = this.$refs.tableSearch.offsetHeight
  314. this.tableHeight = window.innerHeight - tableSearchH - 200
  315. if (this.vinInfoData) {
  316. const vinInfoH = this.$refs.vinInfo.offsetHeight
  317. this.tableHeight = this.tableHeight - vinInfoH
  318. }
  319. }
  320. },
  321. watch: {
  322. advanced (newValue, oldValue) {
  323. this.pageInit()
  324. },
  325. vinInfoData () {
  326. this.pageInit()
  327. },
  328. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  329. this.pageInit()
  330. }
  331. },
  332. mounted () {
  333. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  334. this.pageInit()
  335. this.resetSearchForm()
  336. }
  337. },
  338. activated () {
  339. // 如果是新页签打开,则重置当前页面
  340. if (this.$store.state.app.isNewTab) {
  341. this.pageInit()
  342. this.resetSearchForm()
  343. }
  344. // 仅刷新列表,不重置页面
  345. if (this.$store.state.app.updateList) {
  346. this.pageInit()
  347. this.$refs.table.refresh()
  348. }
  349. },
  350. beforeRouteEnter (to, from, next) {
  351. next(vm => {})
  352. }
  353. }
  354. </script>