chooseProductModal.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  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. <a-upload-dragger :before-upload="beforeUpload" accept="image/*" :showUploadList="false">
  218. <div class="ant-upload-box">
  219. <p class="ant-upload-drag-icon">
  220. <a-icon type="inbox" />
  221. </p>
  222. <p class="ant-upload-text">
  223. 单击或拖动文件到此区域进行上传
  224. </p>
  225. <p class="ant-upload-hint">
  226. 最多一张图片,支持JPG、PNG、BMP格式,最大50M。
  227. </p>
  228. </div>
  229. </a-upload-dragger>
  230. </a-modal>
  231. </a-spin>
  232. </a-drawer>
  233. </template>
  234. <script>
  235. import { Empty } from 'ant-design-vue'
  236. import { commonMixin } from '@/utils/mixin'
  237. import { querySumByProductLocation } from '@/api/stock'
  238. import { warehouseAllList } from '@/api/warehouse'
  239. // 组件
  240. import carInfoModal from './carInfoModal.vue'
  241. import ProductType from '../../common/productType.js'
  242. import ProductBrand from '../../common/productBrand.js'
  243. import { STable, VSelect, Upload } from '@/components'
  244. import { supperCodeByVin, vinCodeParse } from '@/api/sales'
  245. import defImg from '@/assets/def_img@2x.png'
  246. export default {
  247. mixins: [commonMixin],
  248. components: { STable, VSelect, Upload, carInfoModal, ProductType, ProductBrand },
  249. props: {
  250. showModal: { // 显示弹框
  251. type: Boolean,
  252. default: false
  253. },
  254. width: { // 弹框宽度
  255. type: [String, Number],
  256. default: '80%'
  257. },
  258. zIndex: { // 弹框层级
  259. type: Number,
  260. default: 100
  261. },
  262. newLoading: { // 添加按钮loading
  263. type: Boolean
  264. },
  265. checkedList: { // 已选产品列表
  266. type: Array,
  267. default: () => []
  268. },
  269. sourceType: {
  270. type: String,
  271. default: ''
  272. }
  273. },
  274. watch: {
  275. showModal (newValue, oldValue) {
  276. this.visible = newValue
  277. if (newValue) {
  278. // 开始查询列表
  279. this.$refs.searchProductCode.focus()
  280. this.setTableH()
  281. }
  282. },
  283. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  284. this.setTableH()
  285. }
  286. },
  287. data () {
  288. return {
  289. showCell: false, // 显示下拉
  290. spinning: false, // loading动画
  291. showTable: false, // 是否显示表格
  292. visible: this.showModal, // 是否显示弹框
  293. title: '添加产品', // 弹框标题
  294. tableHeight: 0, // 表格高度
  295. tableWidth: 1760, // 表格宽度
  296. simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
  297. advanced: false, // 高级搜索 展开/关闭
  298. vinLoading: false, // vin识别loading
  299. productType: [], // 产品类型
  300. defImg, // 默认图片
  301. showUploadImg: false, // 上传图片弹框
  302. queryParam: { // 查询条件
  303. customerSn: '', // 客户sn
  304. salesBillSn: '', // 销售单sn
  305. salePriceType: '', // 价格类型
  306. productCode: '', // 产品编码
  307. productName: '', // 产品名称
  308. productOrigCode: '', // 原厂编码
  309. vinCode: '', // vin 码
  310. productCodeList: undefined, // 车架号
  311. brandSn: undefined, // 产品品牌
  312. productTypeSn1: '', // 产品一级分类
  313. productTypeSn2: '', // 产品二级分类
  314. productTypeSn3: '', // 产品三级分类
  315. warehouseSn: undefined, // 仓库、
  316. enableFlag: '1', // 启用禁用
  317. existStockFlag: undefined // 是否有库存
  318. },
  319. priceType: '', // 价格类型值
  320. buyerSn: '', // 客户sn
  321. rules: {
  322. vinCode: [ { len: 17, message: '请输入正确的车架号(VIN)', trigger: 'change' } ]
  323. },
  324. disabled: false, // 查询、重置按钮是否可操作
  325. warehouseList: [], // 仓库列表
  326. vinInfoData: null, // vin匹配的车辆信息
  327. // 加载数据方法 必须为 Promise 对象
  328. loadData: parameter => {
  329. const _this = this
  330. _this.queryParam.salePriceType = _this.priceType
  331. _this.queryParam.customerSn = _this.buyerSn
  332. _this.queryParam.sourceType = _this.sourceType
  333. // 排序
  334. if (parameter.sortField == 'productCode') {
  335. parameter.sortField = 'code'
  336. parameter.sortAlias = 'product '
  337. }
  338. if (parameter.sortField == 'brandName') {
  339. parameter.sortField = 'firstChar'
  340. parameter.sortAlias = 'brand'
  341. }
  342. if (parameter.sortField == 'warehouseName') {
  343. parameter.sortField = 'warehouseSn'
  344. parameter.sortAlias = 'sd'
  345. }
  346. // 转单时,productTypeSn3:543766811373752320
  347. if (_this.sourceType === 'TRANSFER_ORDER') {
  348. _this.queryParam.productTypeSn3 = '543766811373752320'
  349. }
  350. const params = Object.assign(parameter, _this.queryParam)
  351. if (_this.queryParam.vinCode && _this.queryParam.vinCode.length == 17 && !this.onlyList) { // 输入vin,查出vin码信息后请求列表数据
  352. _this.disabled = true
  353. return supperCodeByVin({ vin: _this.queryParam.vinCode }).then(res => {
  354. if (res.status == 200) {
  355. _this.vinInfoData = res.data
  356. params.productCodeList = res.data.partCodeList || []
  357. return _this.getList(params)
  358. } else {
  359. _this.vinInfoData = null
  360. _this.$refs.table.localLoading = false
  361. _this.$refs.table.clearTable()
  362. }
  363. })
  364. } else if (_this.queryParam.vinCode && _this.queryParam.vinCode.length < 17 && !this.onlyList) { // 输入vin,但vin码不符合标准,不查vin码信息,不请求列表数据
  365. _this.$refs.table.localLoading = false
  366. _this.$refs.table.clearTable()
  367. } else if (this.onlyList) {
  368. _this.disabled = true
  369. if (_this.queryParam.vinCode && _this.vinInfoData) {
  370. return _this.getList(Object.assign(params, { productCodeList: _this.vinInfoData.partCodeList }))
  371. } else {
  372. return _this.getList(params)
  373. }
  374. } else { // 未输入vin码信息,只查列表数据
  375. _this.disabled = true
  376. return _this.getList(params)
  377. }
  378. },
  379. openModal: false, // 查看客户详情 弹框
  380. cost: false, // 成本价
  381. cityPrice: false, // 城市价
  382. tyuePrice: false, // 特约价
  383. zdPrice: false, // 终端价
  384. openCarInfoModal: false, // 打开车辆信息弹框
  385. onlyList: false // 是否重置条件查询
  386. }
  387. },
  388. computed: {
  389. hasVaild () {
  390. return this.queryParam.productCode || this.queryParam.productName || this.queryParam.brandSn || this.queryParam.productTypeSn1 || this.queryParam.warehouseSn || this.queryParam.existStockFlag || this.queryParam.vinCode
  391. },
  392. columns () {
  393. const _this = this
  394. const arr = [
  395. { title: '产品编码', dataIndex: 'productCode', width: '150px', align: 'center', sorter: true, customRender: function (text) { return text || '--' }, fixed: 'left' },
  396. { title: '产品名称', dataIndex: 'productName', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  397. { title: '原厂编码', dataIndex: 'productOrigCode', width: '150px', align: 'center', customRender: function (text) { return text || '--' } },
  398. { title: '品牌', dataIndex: 'brandName', width: '120px', align: 'center', sorter: true, customRender: function (text) { return text || '--' } }
  399. ]
  400. // 参考成本价
  401. if (this.cost) {
  402. this.tableWidth += 100
  403. arr.push({ slots: { title: 'costTitle' }, dataIndex: 'putCost', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  404. } else {
  405. this.tableWidth -= 100
  406. }
  407. // 市级价
  408. if (this.cityPrice && this.$hasPermissions('M_ShowAllCityPrice')) {
  409. this.tableWidth += 80
  410. arr.push({ title: '市级价', dataIndex: 'dealerProduct.cityPrice', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  411. } else {
  412. this.tableWidth -= 80
  413. }
  414. if (this.tyuePrice) {
  415. this.tableWidth += 80
  416. arr.push({ title: '特约价', dataIndex: 'dealerProduct.specialPrice', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  417. } else {
  418. this.tableWidth -= 80
  419. }
  420. if (this.zdPrice) {
  421. this.tableWidth += 80
  422. arr.push({ title: '终端价', dataIndex: 'dealerProduct.terminalPrice', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  423. } else {
  424. this.tableWidth -= 80
  425. }
  426. return arr.concat([
  427. { title: '仓库', dataIndex: 'warehouseName', width: '120px', align: 'center', customRender: function (text) { return text || '--' } },
  428. { title: '仓位', dataIndex: 'warehouseLocationName', width: '120px', align: 'center', customRender: function (text) { return text || '--' } },
  429. { title: '单位', dataIndex: 'unit', width: '60px', align: 'center', customRender: function (text) { return text || '--' } },
  430. { title: '库存数量', dataIndex: 'currentQty', width: '100px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') }, fixed: 'right' },
  431. { title: '售价', dataIndex: 'salePrice', scopedSlots: { customRender: 'salePrice' }, width: '120px', align: 'center', fixed: 'right' },
  432. { title: '销售数量', dataIndex: 'salesNums', scopedSlots: { customRender: 'nums' }, width: '100px', align: 'center', fixed: 'right' },
  433. { title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' }, width: '120px', align: 'center', fixed: 'right' }
  434. ])
  435. }
  436. },
  437. created () {
  438. // 仓库
  439. if (this.warehouseList.length == 0) {
  440. this.getWarehouse()
  441. }
  442. },
  443. methods: {
  444. // 查询
  445. searchForm () {
  446. if (this.hasVaild) {
  447. this.showTable = true
  448. if (this.$refs.table) {
  449. this.$refs.table.refresh(true)
  450. }
  451. } else {
  452. this.showTable = false
  453. this.$message.info('请输入查询条件')
  454. }
  455. },
  456. getList (params) {
  457. const _this = this
  458. return querySumByProductLocation(params).then(res => {
  459. let data
  460. this.onlyList = false
  461. if (res.status == 200) {
  462. data = res.data
  463. data.list = data.list.filter(item => item != null)
  464. const no = (data.pageNo - 1) * data.pageSize
  465. for (var i = 0; i < data.list.length; i++) {
  466. data.list[i].no = data.list[i].productSn + '_' + (no + i + 1)
  467. data.list[i].salesNums = 1
  468. data.list[i].currentQty = data.list[i].currentQty || 0
  469. 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
  470. data.list[i].productOrigCode = data.list[i].productOrigCode ? data.list[i].productOrigCode.trim() : ''
  471. }
  472. if (!params.vinCode) {
  473. _this.vinInfoData = null
  474. }
  475. } else {
  476. data = {
  477. list: [],
  478. pageNo: 1,
  479. pageSize: 10
  480. }
  481. }
  482. _this.disabled = false
  483. console.log(data)
  484. return data
  485. })
  486. },
  487. // vin change
  488. vinCodeChange (e) {
  489. if (e.target.value.length == 17) {
  490. supperCodeByVin({ vin: e.target.value }).then(res => {
  491. if (res.status == 200) {
  492. this.queryParam.productCodeList = res.data
  493. } else {
  494. this.queryParam.productCodeList = undefined
  495. }
  496. })
  497. } else {
  498. this.queryParam.productCodeList = undefined
  499. }
  500. },
  501. // 双击列表
  502. handleClickRow (record) {
  503. this.handleAdd(record)
  504. },
  505. // 重置
  506. resetSearchForm (flag) {
  507. this.queryParam.productCode = ''
  508. this.queryParam.productName = ''
  509. this.queryParam.productOrigCode = ''
  510. this.queryParam.brandSn = undefined
  511. this.queryParam.productTypeSn1 = ''
  512. this.queryParam.productTypeSn2 = ''
  513. this.queryParam.productTypeSn3 = ''
  514. this.queryParam.warehouseSn = undefined
  515. this.queryParam.productCodeList = undefined
  516. this.queryParam.existStockFlag = undefined
  517. this.queryParam.vinCode = ''
  518. this.productType = []
  519. this.$refs.ruleForm.resetFields()
  520. this.vinInfoData = null
  521. this.showTable = false
  522. if (!flag) {
  523. this.$refs.table.refresh(true)
  524. }
  525. },
  526. pageInit (buyerSn, priceType, salesBillSn) {
  527. this.priceType = priceType || ''
  528. this.buyerSn = buyerSn || ''
  529. this.queryParam.salesBillSn = salesBillSn || ''
  530. },
  531. // 刷新当前页面
  532. resetCurForm () {
  533. this.$refs.table.refresh()
  534. },
  535. // 清空数据
  536. clearTable () {
  537. this.vinInfoData = null
  538. this.$refs.ruleForm.resetFields()
  539. this.$refs.table.clearTable()
  540. },
  541. filterOption (input, option) {
  542. return (
  543. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  544. )
  545. },
  546. // 选择配件
  547. handleAdd (row) {
  548. const _this = this
  549. if (row.lastSalePrice && (row.price < row.salePrice)) {
  550. _this.$confirm({
  551. title: '提示',
  552. content: '售价低于定价,是否仍继续添加?',
  553. centered: true,
  554. closable: true,
  555. onOk () {
  556. _this.$emit('add', row)
  557. }
  558. })
  559. } else {
  560. _this.$emit('add', row)
  561. }
  562. },
  563. // 销售记录
  564. handleDetail (row) {
  565. this.$emit('viewRecord', row)
  566. },
  567. beforeUpload (file) {
  568. const _this = this
  569. console.log(file)
  570. if (file.size > 10240 * 1024 * 5) {
  571. _this.$notification.error({
  572. message: '提示',
  573. description: '文件大小不能超过50M'
  574. })
  575. return false
  576. }
  577. const formData = new FormData()
  578. formData.append('savePathType', 'local')
  579. formData.append('file', file)
  580. // 解析图片
  581. this.vinLoading = true
  582. this.disabled = true
  583. vinCodeParse(formData).then(res => {
  584. if (res.type == 'application/json') {
  585. var reader = new FileReader()
  586. reader.addEventListener('loadend', function () {
  587. const obj = JSON.parse(reader.result)
  588. if (obj.status == 200) {
  589. _this.queryParam.vinCode = obj.data || ''
  590. // 移除表单项的校验结果
  591. _this.$refs.ruleForm.clearValidate('vinCode')
  592. _this.showUploadImg = false
  593. } else {
  594. _this.$notification.error({
  595. message: '提示',
  596. description: obj.message
  597. })
  598. }
  599. _this.vinLoading = false
  600. _this.disabled = false
  601. })
  602. reader.readAsText(res)
  603. } else {
  604. _this.vinLoading = false
  605. _this.disabled = false
  606. }
  607. })
  608. return false
  609. },
  610. // 仓库
  611. getWarehouse () {
  612. warehouseAllList({ wasteFlag: 0 }).then(res => {
  613. if (res.status == 200) {
  614. this.warehouseList = res.data
  615. } else {
  616. this.warehouseList = []
  617. }
  618. })
  619. },
  620. // 产品分类 change
  621. changeProductType (val, opt) {
  622. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  623. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  624. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  625. },
  626. // 查看是否有库存、
  627. handleHasQty (val) {
  628. this.queryParam.existStockFlag = val
  629. },
  630. onClose () {
  631. this.resetSearchForm(true)
  632. this.$emit('close')
  633. },
  634. setTableH () {
  635. this.$nextTick(() => {
  636. const searchBoxH = this.$refs.searchBox.offsetHeight
  637. this.tableHeight = window.innerHeight - searchBoxH - 245
  638. })
  639. }
  640. }
  641. }
  642. </script>
  643. <style lang="less">
  644. .uploadimg-modal{
  645. .ant-upload-box{
  646. text-align: center;
  647. width:100%;
  648. .ant-upload-text {
  649. margin: 0 0 4px;
  650. color: rgba(0, 0, 0, .85);
  651. font-size: 16px;
  652. }
  653. .ant-upload-hint {
  654. color: rgba(0, 0, 0, .45);
  655. font-size: 14px;
  656. }
  657. .ant-upload-drag-icon .anticon {
  658. color: #40a9ff;
  659. font-size: 48px;
  660. }
  661. }
  662. }
  663. .chooseProduct-drawer {
  664. .ant-drawer-header{
  665. padding: 13px 20px;
  666. }
  667. .ant-drawer-body {
  668. padding: 15px 20px;
  669. height: calc(100% - 50px);
  670. display: flex;
  671. flex-direction: column;
  672. overflow: auto;
  673. > div {
  674. height: 100%;
  675. }
  676. .noStock{
  677. text-decoration: line-through;
  678. color: red;
  679. }
  680. .ant-input-number-sm input{
  681. text-align: center;
  682. }
  683. .vinInfo-box{
  684. display: flex;
  685. justify-content: space-between;
  686. align-items: center;
  687. .vinInfo-error{
  688. color: red;
  689. }
  690. }
  691. }
  692. .vininputs{
  693. .ant-input-group-addon{
  694. padding: 0;
  695. border:0;
  696. border-left: 1px solid #e7e7e7;
  697. }
  698. }
  699. }
  700. </style>