chooseProductModal.vue 32 KB

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