chooseProductModal.vue 25 KB

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