chooseProductModal.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. <template>
  2. <a-drawer
  3. :zIndex="zIndex"
  4. :title="title"
  5. placement="right"
  6. :visible="visible"
  7. :width="width"
  8. :get-container="false"
  9. :wrap-style="{ position: 'absolute' }"
  10. @close="onClose"
  11. wrapClassName="chooseProduct-drawer jg-drawer-wrap">
  12. <a-spin :spinning="spinning||newLoading" tip="Loading...">
  13. <!-- 搜索条件 -->
  14. <div ref="searchBox" class="table-page-search-wrapper">
  15. <a-form-model
  16. ref="ruleForm"
  17. class="form-model-con"
  18. layout="inline"
  19. :rules="rules"
  20. :model="queryParam"
  21. @keyup.enter.native="$refs.table.refresh(true)" >
  22. <a-row type="flex" :gutter="5">
  23. <a-col flex="1">
  24. <a-form-model-item label="产品编码">
  25. <a-input id="productInfoList-code" ref="searchProductCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  26. </a-form-model-item>
  27. </a-col>
  28. <a-col flex="1">
  29. <a-form-model-item label="产品名称">
  30. <a-input id="productInfoList-name" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  31. </a-form-model-item>
  32. </a-col>
  33. <a-col flex="1">
  34. <a-form-model-item label="原厂编码">
  35. <a-input id="productInfoList-origCode" v-model.trim="queryParam.productOrigCode" allowClear placeholder="请输入原厂编码"/>
  36. </a-form-model-item>
  37. </a-col>
  38. <a-col flex="1">
  39. <a-form-model-item label="产品品牌">
  40. <ProductBrand id="productInfoList-productBrandSn" v-model="queryParam.brandSn"></ProductBrand>
  41. </a-form-model-item>
  42. </a-col>
  43. </a-row>
  44. <a-row type="flex" :gutter="5">
  45. <a-col flex="1.5">
  46. <a-form-model-item label="产品分类">
  47. <ProductType id="productInfoList-productType" :isDealer="true" @change="changeProductType" v-model="productType"></ProductType>
  48. </a-form-model-item>
  49. </a-col>
  50. <a-col flex="1.5">
  51. <a-form-model-item label="仓库">
  52. <a-select
  53. placeholder="请选择仓库"
  54. id="productInfoList-warehouseSn"
  55. allowClear
  56. v-model="queryParam.warehouseSn"
  57. :showSearch="true"
  58. option-filter-prop="children"
  59. :filter-option="filterOption">
  60. <a-select-option v-for="item in warehouseList" :key="item.warehouseSn" :value="item.warehouseSn">{{ item.name }}</a-select-option>
  61. </a-select>
  62. </a-form-model-item>
  63. </a-col>
  64. <a-col flex="2" v-if="$hasPermissions('B_salerVinFindProduct')&&sourceType !== 'TRANSFER_ORDER'">
  65. <a-form-model-item label="车架号(VIN)" prop="vinCode" class="vininputs">
  66. <a-input id="productInfoList-vinCode" v-model.trim="queryParam.vinCode" allowClear placeholder="请输入车架号(VIN)">
  67. <a-icon slot="addonAfter" @click="showUploadImg=true" :type="vinLoading?'loading':'camera'" :style="{ fontSize: '18px', verticalAlign: 'bottom',cursor:'pointer',padding:'0 10px' }" title="点击拖动图片识别VIN" />
  68. </a-input>
  69. </a-form-model-item>
  70. </a-col>
  71. <a-col flex="200px">
  72. <a-form-item label="是否有库存">
  73. <a-select id="productInfoList-existStockFlag" @change="handleHasQty" allowClear :value="queryParam.existStockFlag" placeholder="请选择是否">
  74. <a-select-option value="1">
  75. </a-select-option>
  76. <a-select-option value="0">
  77. </a-select-option>
  78. </a-select>
  79. </a-form-item>
  80. </a-col>
  81. <a-col flex="auto">
  82. <a-button type="primary" @click="searchForm()" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  83. <a-button style="margin-left: 5px" @click="resetSearchForm" id="productInfoList-reset">重置</a-button>
  84. </a-col>
  85. </a-row>
  86. </a-form-model>
  87. <!-- 查看更多 -->
  88. <div v-if="hasVaild&&showTable" class="vinInfo-box">
  89. <div>
  90. <div class="vinInfo-error" v-if="vinInfoData&&!vinInfoData.carInfo">
  91. <a-icon type="exclamation-circle" :style="{ color: '#E70012', fontSize: '15px', verticalAlign: 'sub', marginRight: '3px' }" />抱歉!暂未找到匹配VIN码的车型!
  92. </div>
  93. <div v-if="vinInfoData&&vinInfoData.carInfo" id="productInfoList-carinfo" @click="openCarInfoModal=true">
  94. <div style="display: flex;justify-content: space-between;align-items: center;" id="productInfoList-carinfoMoadl" @click="openCarInfoModal=true">
  95. <div>
  96. <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;" />
  97. <span style="vertical-align: middle;">{{ vinInfoData.carInfo.brandName }} {{ vinInfoData.carInfo.modelName }} {{ vinInfoData.carInfo.displacement }} {{ vinInfoData.carInfo.modelYear+'年' }}</span>
  98. </div>
  99. <div style="color: #f90;cursor: pointer;margin-left: 5px;">
  100. <span>查看详情</span> >
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. <div>
  106. <a-dropdown v-model="showCell">
  107. <a class="ant-dropdown-link" id="productInfoList-showCell" @click="e => e.preventDefault()">
  108. <a-icon type="setting" /> 显示
  109. </a>
  110. <a-menu slot="overlay" id="productInfoList-showMenu">
  111. <a-menu-item v-if="$hasPermissions('M_ShowAllCost')" >
  112. <a-checkbox v-model="cost" id="salesQuery-cost">成本价</a-checkbox>
  113. </a-menu-item>
  114. <a-menu-item v-if="$hasPermissions('M_ShowAllCityPrice')&&$store.state.user.dealerLevel != 'SPECIAL'">
  115. <a-checkbox v-model="cityPrice" id="salesQuery-cityPrice">市级价</a-checkbox>
  116. </a-menu-item>
  117. <a-menu-item v-if="$store.state.user.isShowSpecialPrice==1" >
  118. <a-checkbox v-model="tyuePrice"id="salesQuery-tyuePrice">特约价</a-checkbox>
  119. </a-menu-item>
  120. <a-menu-item>
  121. <a-checkbox v-model="zdPrice" id="salesQuery-zdPrice">终端价</a-checkbox>
  122. </a-menu-item>
  123. </a-menu>
  124. </a-dropdown>
  125. </div>
  126. </div>
  127. </div>
  128. <!-- 列表 -->
  129. <s-table
  130. v-if="hasVaild&&showTable"
  131. class="sTable"
  132. ref="table"
  133. size="small"
  134. :rowKey="(record) => record.no"
  135. rowKeyName="no"
  136. :columns="columns"
  137. :data="loadData"
  138. @dblclick="handleClickRow"
  139. :pageSize="30"
  140. :scroll="{ y: tableHeight, x: tableWidth }"
  141. bordered>
  142. <div slot="costTitle">
  143. <a-tooltip placement="top">
  144. <template slot="title">
  145. 产品所在仓库仓位的最近一次入库成本,不包含盘盈入库和仓库调拨入库。
  146. </template>
  147. <span style="margin-right: 5px;">参考成本价</span> <a-icon type="question-circle" />
  148. </a-tooltip>
  149. </div>
  150. <!-- 售价 -->
  151. <template slot="salePrice" slot-scope="text, record">
  152. <div style="display: flex;align-items: center;" @dblclick.stop>
  153. <a-input-number
  154. :id="'productInfoList-price-'+record.id"
  155. size="small"
  156. v-model="record.price"
  157. :precision="2"
  158. :min="0"
  159. :max="999999"
  160. style="width: 100%;"
  161. placeholder="请输入" />
  162. <span style="color: red;margin: 0 2px;font-size: 14px;" v-if="record.origSalePriceFlag == 1">原</span>
  163. <span v-else>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
  164. </div>
  165. </template>
  166. <!-- 销售数量 -->
  167. <template slot="nums" slot-scope="text, record">
  168. <div @dblclick.stop>
  169. <a-input-number
  170. :id="'productInfoList-mums-'+record.id"
  171. size="small"
  172. v-model="record.salesNums"
  173. :precision="0"
  174. :min="0"
  175. :max="999999"
  176. style="width: 100%;"
  177. placeholder="请输入" />
  178. </div>
  179. </template>
  180. <!-- 操作 -->
  181. <template slot="action" slot-scope="text, record">
  182. <a-button
  183. size="small"
  184. type="link"
  185. class="button-primary"
  186. @click.stop="handleAdd(record)"
  187. :id="'productInfoList-add-'+record.id">添加</a-button>
  188. <a-button
  189. size="small"
  190. type="link"
  191. class="button-primary"
  192. @click.stop="handleDetail(record)"
  193. :id="'productInfoList-record-'+record.id"
  194. style="margin-left: 5px;">销售记录</a-button>
  195. </template>
  196. </s-table>
  197. <div style="padding-top: 30px;" v-else>
  198. <a-empty
  199. :image="simpleImage"
  200. :image-style="{
  201. height: '60px',
  202. }"
  203. >
  204. <span style="color:red" slot="description">请输入查询条件</span>
  205. </a-empty>
  206. </div>
  207. <!-- 查看车辆信息 -->
  208. <car-info-modal ref="carInfoModal" :openModal="openCarInfoModal" :infoData="vinInfoData&&vinInfoData.carInfo" @close="openCarInfoModal=false" />
  209. <!-- 上传图片弹窗 -->
  210. <a-modal
  211. v-model="showUploadImg"
  212. class="uploadimg-modal"
  213. title="上传图片识别VIN"
  214. :footer="null"
  215. centered
  216. @ok="showUploadImg=false">
  217. <div>
  218. <a-upload-dragger :before-upload="beforeUpload" accept="image/*" :showUploadList="false">
  219. <div class="ant-upload-box">
  220. <p class="ant-upload-drag-icon">
  221. <a-icon type="inbox" />
  222. </p>
  223. <p class="ant-upload-text">
  224. 单击或拖动文件到此区域进行上传
  225. </p>
  226. <p class="ant-upload-hint">
  227. 最多一张图片,支持JPG、PNG、BMP格式,最大50M。
  228. </p>
  229. </div>
  230. </a-upload-dragger>
  231. <div>
  232. <p></p>
  233. <p><strong>系统声明:</strong></p>
  234. <p>1、本系统仅作为查询辅助工具,在使用中如有对数据与实车配件产品不匹配疑问时,请务必核实实车配件产品及原车维修保养手册所推荐产品标准;</p>
  235. <p>2、本系统查询数据仅供参考,请以车辆用户手册为准,一切查询数据均不可作为任何法律和纠错依据或证据。</p>
  236. </div>
  237. </div>
  238. </a-modal>
  239. </a-spin>
  240. </a-drawer>
  241. </template>
  242. <script>
  243. import { Empty } from 'ant-design-vue'
  244. import { commonMixin } from '@/utils/mixin'
  245. import { querySumByProductLocation } from '@/api/stock'
  246. import { warehouseAllList } from '@/api/warehouse'
  247. // 组件
  248. import carInfoModal from './carInfoModal.vue'
  249. import ProductType from '../../common/productType.js'
  250. import ProductBrand from '../../common/productBrand.js'
  251. import { STable, VSelect, Upload } from '@/components'
  252. import { supperCodeByVin, vinCodeParse } from '@/api/sales'
  253. import defImg from '@/assets/def_img@2x.png'
  254. export default {
  255. mixins: [commonMixin],
  256. components: { STable, VSelect, Upload, carInfoModal, ProductType, ProductBrand },
  257. props: {
  258. showModal: { // 显示弹框
  259. type: Boolean,
  260. default: false
  261. },
  262. width: { // 弹框宽度
  263. type: [String, Number],
  264. default: '80%'
  265. },
  266. zIndex: { // 弹框层级
  267. type: Number,
  268. default: 100
  269. },
  270. newLoading: { // 添加按钮loading
  271. type: Boolean
  272. },
  273. checkedList: { // 已选产品列表
  274. type: Array,
  275. default: () => []
  276. },
  277. sourceType: {
  278. type: String,
  279. default: ''
  280. }
  281. },
  282. watch: {
  283. showModal (newValue, oldValue) {
  284. this.visible = newValue
  285. if (newValue) {
  286. // 开始查询列表
  287. this.$refs.searchProductCode.focus()
  288. this.setTableH()
  289. }
  290. },
  291. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  292. this.setTableH()
  293. }
  294. },
  295. data () {
  296. return {
  297. showCell: false, // 显示下拉
  298. spinning: false, // loading动画
  299. showTable: false, // 是否显示表格
  300. visible: this.showModal, // 是否显示弹框
  301. title: '添加产品', // 弹框标题
  302. tableHeight: 0, // 表格高度
  303. tableWidth: 1760, // 表格宽度
  304. simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
  305. advanced: false, // 高级搜索 展开/关闭
  306. vinLoading: false, // vin识别loading
  307. productType: [], // 产品类型
  308. defImg, // 默认图片
  309. showUploadImg: false, // 上传图片弹框
  310. queryParam: { // 查询条件
  311. customerSn: '', // 客户sn
  312. salesBillSn: '', // 销售单sn
  313. salePriceType: '', // 价格类型
  314. productCode: '', // 产品编码
  315. productName: '', // 产品名称
  316. productOrigCode: '', // 原厂编码
  317. vinCode: '', // vin 码
  318. productCodeList: undefined, // 车架号
  319. brandSn: undefined, // 产品品牌
  320. productTypeSn1: '', // 产品一级分类
  321. productTypeSn2: '', // 产品二级分类
  322. productTypeSn3: '', // 产品三级分类
  323. warehouseSn: undefined, // 仓库、
  324. enableFlag: '1', // 启用禁用
  325. existStockFlag: undefined // 是否有库存
  326. },
  327. priceType: '', // 价格类型值
  328. buyerSn: '', // 客户sn
  329. rules: {
  330. vinCode: [ { len: 17, message: '请输入正确的车架号(VIN)', trigger: 'change' } ]
  331. },
  332. disabled: false, // 查询、重置按钮是否可操作
  333. warehouseList: [], // 仓库列表
  334. vinInfoData: null, // vin匹配的车辆信息
  335. // 加载数据方法 必须为 Promise 对象
  336. loadData: parameter => {
  337. const _this = this
  338. _this.queryParam.salePriceType = _this.priceType
  339. _this.queryParam.customerSn = _this.buyerSn
  340. _this.queryParam.sourceType = _this.sourceType
  341. // 排序
  342. if (parameter.sortField == 'productCode') {
  343. parameter.sortField = 'code'
  344. parameter.sortAlias = 'product '
  345. }
  346. if (parameter.sortField == 'brandName') {
  347. parameter.sortField = 'firstChar'
  348. parameter.sortAlias = 'brand'
  349. }
  350. if (parameter.sortField == 'warehouseName') {
  351. parameter.sortField = 'warehouseSn'
  352. parameter.sortAlias = 'sd'
  353. }
  354. // 转单时,productTypeSn3:543766811373752320
  355. if (_this.sourceType === 'TRANSFER_ORDER') {
  356. _this.queryParam.productTypeSn3 = '543766811373752320'
  357. }
  358. const params = Object.assign(parameter, _this.queryParam)
  359. if (_this.queryParam.vinCode && _this.queryParam.vinCode.length == 17 && !this.onlyList) { // 输入vin,查出vin码信息后请求列表数据
  360. _this.disabled = true
  361. return supperCodeByVin({ vin: _this.queryParam.vinCode }).then(res => {
  362. if (res.status == 200) {
  363. _this.vinInfoData = res.data
  364. params.productCodeList = res.data.partCodeList || []
  365. return _this.getList(params)
  366. } else {
  367. _this.vinInfoData = null
  368. _this.$refs.table.localLoading = false
  369. _this.$refs.table.clearTable()
  370. }
  371. })
  372. } else if (_this.queryParam.vinCode && _this.queryParam.vinCode.length < 17 && !this.onlyList) { // 输入vin,但vin码不符合标准,不查vin码信息,不请求列表数据
  373. _this.$refs.table.localLoading = false
  374. _this.$refs.table.clearTable()
  375. } else if (this.onlyList) {
  376. _this.disabled = true
  377. if (_this.queryParam.vinCode && _this.vinInfoData) {
  378. return _this.getList(Object.assign(params, { productCodeList: _this.vinInfoData.partCodeList }))
  379. } else {
  380. return _this.getList(params)
  381. }
  382. } else { // 未输入vin码信息,只查列表数据
  383. _this.disabled = true
  384. return _this.getList(params)
  385. }
  386. },
  387. openModal: false, // 查看客户详情 弹框
  388. cost: false, // 成本价
  389. cityPrice: false, // 城市价
  390. tyuePrice: false, // 特约价
  391. zdPrice: false, // 终端价
  392. openCarInfoModal: false, // 打开车辆信息弹框
  393. onlyList: false // 是否重置条件查询
  394. }
  395. },
  396. computed: {
  397. hasVaild () {
  398. return this.queryParam.productCode || this.queryParam.productName || this.queryParam.brandSn || this.queryParam.productTypeSn1 || this.queryParam.warehouseSn || this.queryParam.existStockFlag || this.queryParam.vinCode
  399. },
  400. columns () {
  401. const _this = this
  402. const arr = [
  403. { title: '产品编码', dataIndex: 'productCode', width: '150px', align: 'center', sorter: true, customRender: function (text) { return text || '--' }, fixed: 'left' },
  404. { title: '产品名称', dataIndex: 'productName', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  405. { title: '原厂编码', dataIndex: 'productOrigCode', width: '150px', align: 'center', customRender: function (text) { return text || '--' } },
  406. { title: '品牌', dataIndex: 'brandName', width: '120px', align: 'center', sorter: true, customRender: function (text) { return text || '--' } }
  407. ]
  408. // 参考成本价
  409. if (this.cost) {
  410. this.tableWidth += 100
  411. arr.push({ slots: { title: 'costTitle' }, dataIndex: 'putCost', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  412. } else {
  413. this.tableWidth -= 100
  414. }
  415. // 市级价
  416. if (this.cityPrice && this.$hasPermissions('M_ShowAllCityPrice')) {
  417. this.tableWidth += 80
  418. arr.push({ title: '市级价', dataIndex: 'dealerProduct.cityPrice', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  419. } else {
  420. this.tableWidth -= 80
  421. }
  422. if (this.tyuePrice) {
  423. this.tableWidth += 80
  424. arr.push({ title: '特约价', dataIndex: 'dealerProduct.specialPrice', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  425. } else {
  426. this.tableWidth -= 80
  427. }
  428. if (this.zdPrice) {
  429. this.tableWidth += 80
  430. arr.push({ title: '终端价', dataIndex: 'dealerProduct.terminalPrice', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  431. } else {
  432. this.tableWidth -= 80
  433. }
  434. return arr.concat([
  435. { title: '仓库', dataIndex: 'warehouseName', width: '120px', align: 'center', customRender: function (text) { return text || '--' } },
  436. { title: '仓位', dataIndex: 'warehouseLocationName', width: '120px', align: 'center', customRender: function (text) { return text || '--' } },
  437. { title: '单位', dataIndex: 'unit', width: '60px', align: 'center', customRender: function (text) { return text || '--' } },
  438. { title: '库存数量', dataIndex: 'currentQty', width: '100px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') }, fixed: 'right' },
  439. { title: '售价', dataIndex: 'salePrice', scopedSlots: { customRender: 'salePrice' }, width: '120px', align: 'center', fixed: 'right' },
  440. { title: '销售数量', dataIndex: 'salesNums', scopedSlots: { customRender: 'nums' }, width: '100px', align: 'center', fixed: 'right' },
  441. { title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' }, width: '120px', align: 'center', fixed: 'right' }
  442. ])
  443. }
  444. },
  445. created () {
  446. // 仓库
  447. if (this.warehouseList.length == 0) {
  448. this.getWarehouse()
  449. }
  450. },
  451. methods: {
  452. // 查询
  453. searchForm () {
  454. if (this.hasVaild) {
  455. this.showTable = true
  456. if (this.$refs.table) {
  457. this.$refs.table.refresh(true)
  458. }
  459. } else {
  460. this.showTable = false
  461. this.$message.info('请输入查询条件')
  462. }
  463. },
  464. getList (params) {
  465. const _this = this
  466. return querySumByProductLocation(params).then(res => {
  467. let data
  468. this.onlyList = false
  469. if (res.status == 200) {
  470. data = res.data
  471. data.list = data.list.filter(item => item != null)
  472. const no = (data.pageNo - 1) * data.pageSize
  473. for (var i = 0; i < data.list.length; i++) {
  474. data.list[i].no = data.list[i].productSn + '_' + (no + i + 1)
  475. data.list[i].salesNums = 1
  476. data.list[i].currentQty = data.list[i].currentQty || 0
  477. data.list[i].price = data.list[i].origSalePriceFlag == 0 ? data.list[i].lastSalePrice : data.list[i].origSalePriceFlag == 1 ? data.list[i].salePrice : data.list[i].selfSaleprice
  478. data.list[i].productOrigCode = data.list[i].productOrigCode ? data.list[i].productOrigCode.trim() : ''
  479. }
  480. if (!params.vinCode) {
  481. _this.vinInfoData = null
  482. }
  483. } else {
  484. data = {
  485. list: [],
  486. pageNo: 1,
  487. pageSize: 10
  488. }
  489. }
  490. _this.disabled = false
  491. console.log(data)
  492. return data
  493. })
  494. },
  495. // vin change
  496. vinCodeChange (e) {
  497. if (e.target.value.length == 17) {
  498. supperCodeByVin({ vin: e.target.value }).then(res => {
  499. if (res.status == 200) {
  500. this.queryParam.productCodeList = res.data
  501. } else {
  502. this.queryParam.productCodeList = undefined
  503. }
  504. })
  505. } else {
  506. this.queryParam.productCodeList = undefined
  507. }
  508. },
  509. // 双击列表
  510. handleClickRow (record) {
  511. this.handleAdd(record)
  512. },
  513. // 重置
  514. resetSearchForm (flag) {
  515. this.queryParam.productCode = ''
  516. this.queryParam.productName = ''
  517. this.queryParam.productOrigCode = ''
  518. this.queryParam.brandSn = undefined
  519. this.queryParam.productTypeSn1 = ''
  520. this.queryParam.productTypeSn2 = ''
  521. this.queryParam.productTypeSn3 = ''
  522. this.queryParam.warehouseSn = undefined
  523. this.queryParam.productCodeList = undefined
  524. this.queryParam.existStockFlag = undefined
  525. this.queryParam.vinCode = ''
  526. this.productType = []
  527. this.$refs.ruleForm.resetFields()
  528. this.vinInfoData = null
  529. this.showTable = false
  530. if (!flag) {
  531. this.$refs.table.refresh(true)
  532. }
  533. },
  534. pageInit (buyerSn, priceType, salesBillSn) {
  535. this.priceType = priceType || ''
  536. this.buyerSn = buyerSn || ''
  537. this.queryParam.salesBillSn = salesBillSn || ''
  538. },
  539. // 刷新当前页面
  540. resetCurForm () {
  541. this.$refs.table.refresh()
  542. },
  543. // 清空数据
  544. clearTable () {
  545. this.vinInfoData = null
  546. this.$refs.ruleForm.resetFields()
  547. this.$refs.table.clearTable()
  548. },
  549. filterOption (input, option) {
  550. return (
  551. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  552. )
  553. },
  554. // 选择配件
  555. handleAdd (row) {
  556. const _this = this
  557. if (row.lastSalePrice && (row.price < row.salePrice)) {
  558. _this.$confirm({
  559. title: '提示',
  560. content: '售价低于定价,是否仍继续添加?',
  561. centered: true,
  562. closable: true,
  563. onOk () {
  564. _this.$emit('add', row)
  565. }
  566. })
  567. } else {
  568. _this.$emit('add', row)
  569. }
  570. },
  571. // 销售记录
  572. handleDetail (row) {
  573. this.$emit('viewRecord', row)
  574. },
  575. beforeUpload (file) {
  576. const _this = this
  577. console.log(file)
  578. if (file.size > 10240 * 1024 * 5) {
  579. _this.$notification.error({
  580. message: '提示',
  581. description: '文件大小不能超过50M'
  582. })
  583. return false
  584. }
  585. const formData = new FormData()
  586. formData.append('savePathType', 'local')
  587. formData.append('file', file)
  588. // 解析图片
  589. this.vinLoading = true
  590. this.disabled = true
  591. vinCodeParse(formData).then(res => {
  592. if (res.type == 'application/json') {
  593. var reader = new FileReader()
  594. reader.addEventListener('loadend', function () {
  595. const obj = JSON.parse(reader.result)
  596. if (obj.status == 200) {
  597. _this.queryParam.vinCode = obj.data || ''
  598. // 移除表单项的校验结果
  599. _this.$refs.ruleForm.clearValidate('vinCode')
  600. _this.showUploadImg = false
  601. _this.searchForm()
  602. } else {
  603. _this.$notification.error({
  604. message: '提示',
  605. description: obj.message
  606. })
  607. }
  608. _this.vinLoading = false
  609. _this.disabled = false
  610. })
  611. reader.readAsText(res)
  612. } else {
  613. _this.vinLoading = false
  614. _this.disabled = false
  615. }
  616. })
  617. return false
  618. },
  619. // 仓库
  620. getWarehouse () {
  621. warehouseAllList({ wasteFlag: 0 }).then(res => {
  622. if (res.status == 200) {
  623. this.warehouseList = res.data
  624. } else {
  625. this.warehouseList = []
  626. }
  627. })
  628. },
  629. // 产品分类 change
  630. changeProductType (val, opt) {
  631. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  632. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  633. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  634. },
  635. // 查看是否有库存、
  636. handleHasQty (val) {
  637. this.queryParam.existStockFlag = val
  638. },
  639. onClose () {
  640. this.resetSearchForm(true)
  641. this.$emit('close')
  642. },
  643. setTableH () {
  644. this.$nextTick(() => {
  645. const searchBoxH = this.$refs.searchBox.offsetHeight
  646. this.tableHeight = window.innerHeight - searchBoxH - 245
  647. })
  648. }
  649. }
  650. }
  651. </script>
  652. <style lang="less">
  653. .uploadimg-modal{
  654. .ant-upload-box{
  655. text-align: center;
  656. width:100%;
  657. .ant-upload-text {
  658. margin: 0 0 4px;
  659. color: rgba(0, 0, 0, .85);
  660. font-size: 16px;
  661. }
  662. .ant-upload-hint {
  663. color: rgba(0, 0, 0, .45);
  664. font-size: 14px;
  665. }
  666. .ant-upload-drag-icon .anticon {
  667. color: #40a9ff;
  668. font-size: 48px;
  669. }
  670. }
  671. }
  672. .chooseProduct-drawer {
  673. .ant-drawer-header{
  674. padding: 13px 20px;
  675. }
  676. .ant-drawer-body {
  677. padding: 15px 20px;
  678. height: calc(100% - 50px);
  679. display: flex;
  680. flex-direction: column;
  681. overflow: auto;
  682. > div {
  683. height: 100%;
  684. }
  685. .noStock{
  686. text-decoration: line-through;
  687. color: red;
  688. }
  689. .ant-input-number-sm input{
  690. text-align: center;
  691. }
  692. .vinInfo-box{
  693. display: flex;
  694. justify-content: space-between;
  695. align-items: center;
  696. .vinInfo-error{
  697. color: red;
  698. }
  699. }
  700. }
  701. .vininputs{
  702. .ant-input-group-addon{
  703. padding: 0;
  704. border:0;
  705. border-left: 1px solid #e7e7e7;
  706. }
  707. }
  708. }
  709. </style>