chooseProductModal.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  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. // 排序
  311. if (parameter.sortField == 'productCode') {
  312. parameter.sortField = 'code'
  313. parameter.sortAlias = 'product '
  314. }
  315. if (parameter.sortField == 'brandName') {
  316. parameter.sortField = 'firstChar'
  317. parameter.sortAlias = 'brand'
  318. }
  319. if (parameter.sortField == 'warehouseName') {
  320. parameter.sortField = 'warehouseSn'
  321. parameter.sortAlias = 'sd'
  322. }
  323. // 转单时,productTypeSn3:543766811373752320
  324. if (_this.sourceType === 'TRANSFER_ORDER') {
  325. _this.queryParam.productTypeSn3 = '543766811373752320'
  326. }
  327. const params = Object.assign(parameter, _this.queryParam)
  328. if (_this.queryParam.vinCode && _this.queryParam.vinCode.length == 17 && !this.onlyList) { // 输入vin,查出vin码信息后请求列表数据
  329. _this.disabled = true
  330. return supperCodeByVin({ vin: _this.queryParam.vinCode }).then(res => {
  331. if (res.status == 200) {
  332. _this.vinInfoData = res.data
  333. params.productCodeList = res.data.partCodeList || []
  334. return _this.getList(params)
  335. } else {
  336. _this.vinInfoData = null
  337. _this.$refs.table.localLoading = false
  338. _this.$refs.table.clearTable()
  339. }
  340. })
  341. } else if (_this.queryParam.vinCode && _this.queryParam.vinCode.length < 17 && !this.onlyList) { // 输入vin,但vin码不符合标准,不查vin码信息,不请求列表数据
  342. _this.$refs.table.localLoading = false
  343. _this.$refs.table.clearTable()
  344. } else if (this.onlyList) {
  345. _this.disabled = true
  346. if (_this.queryParam.vinCode && _this.vinInfoData) {
  347. return _this.getList(Object.assign(params, { productCodeList: _this.vinInfoData.partCodeList }))
  348. } else {
  349. return _this.getList(params)
  350. }
  351. } else { // 未输入vin码信息,只查列表数据
  352. _this.disabled = true
  353. return _this.getList(params)
  354. }
  355. },
  356. openModal: false, // 查看客户详情 弹框
  357. cost: false, // 成本价
  358. cityPrice: false, // 城市价
  359. tyuePrice: false, // 特约价
  360. zdPrice: false, // 终端价
  361. openCarInfoModal: false, // 打开车辆信息弹框
  362. onlyList: false // 是否重置条件查询
  363. }
  364. },
  365. computed: {
  366. hasVaild () {
  367. return this.queryParam.productCode || this.queryParam.productName || this.queryParam.brandSn || this.queryParam.productTypeSn1 || this.queryParam.warehouseSn || this.queryParam.existStockFlag || this.queryParam.vinCode
  368. },
  369. columns () {
  370. const _this = this
  371. const arr = [
  372. { title: '产品编码', dataIndex: 'productCode', width: '150px', align: 'center', sorter: true, customRender: function (text) { return text || '--' }, fixed: 'left' },
  373. { title: '产品名称', dataIndex: 'productName', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  374. { title: '原厂编码', dataIndex: 'productOrigCode', width: '150px', align: 'center', customRender: function (text) { return text || '--' } },
  375. { title: '品牌', dataIndex: 'brandName', width: '120px', align: 'center', sorter: true, customRender: function (text) { return text || '--' } }
  376. ]
  377. // 参考成本价
  378. if (this.cost) {
  379. this.tableWidth += 100
  380. arr.push({ slots: { title: 'costTitle' }, dataIndex: 'putCost', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  381. } else {
  382. this.tableWidth -= 100
  383. }
  384. // 市级价
  385. if (this.cityPrice && this.$hasPermissions('M_ShowAllCityPrice')) {
  386. this.tableWidth += 80
  387. arr.push({ title: '市级价', dataIndex: 'dealerProduct.cityPrice', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  388. } else {
  389. this.tableWidth -= 80
  390. }
  391. if (this.tyuePrice) {
  392. this.tableWidth += 80
  393. arr.push({ title: '特约价', dataIndex: 'dealerProduct.specialPrice', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  394. } else {
  395. this.tableWidth -= 80
  396. }
  397. if (this.zdPrice) {
  398. this.tableWidth += 80
  399. arr.push({ title: '终端价', dataIndex: 'dealerProduct.terminalPrice', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  400. } else {
  401. this.tableWidth -= 80
  402. }
  403. return arr.concat([
  404. { title: '仓库', dataIndex: 'warehouseName', width: '120px', align: 'center', customRender: function (text) { return text || '--' } },
  405. { title: '仓位', dataIndex: 'warehouseLocationName', width: '120px', align: 'center', customRender: function (text) { return text || '--' } },
  406. { title: '单位', dataIndex: 'unit', width: '60px', align: 'center', customRender: function (text) { return text || '--' } },
  407. { title: '库存数量', dataIndex: 'currentQty', width: '100px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') }, fixed: 'right' },
  408. { title: '售价', dataIndex: 'salePrice', scopedSlots: { customRender: 'salePrice' }, width: '120px', align: 'center', fixed: 'right' },
  409. { title: '销售数量', dataIndex: 'salesNums', scopedSlots: { customRender: 'nums' }, width: '100px', align: 'center', fixed: 'right' },
  410. { title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' }, width: '120px', align: 'center', fixed: 'right' }
  411. ])
  412. }
  413. },
  414. created () {
  415. // 仓库
  416. if (this.warehouseList.length == 0) {
  417. this.getWarehouse()
  418. }
  419. },
  420. methods: {
  421. // 查询
  422. searchForm () {
  423. if (this.hasVaild) {
  424. this.showTable = true
  425. if (this.$refs.table) {
  426. this.$refs.table.refresh(true)
  427. }
  428. } else {
  429. this.showTable = false
  430. this.$message.info('请输入查询条件')
  431. }
  432. },
  433. getList (params) {
  434. const _this = this
  435. return querySumByProductLocation(params).then(res => {
  436. let data
  437. this.onlyList = false
  438. if (res.status == 200) {
  439. data = res.data
  440. data.list = data.list.filter(item => item != null)
  441. const no = (data.pageNo - 1) * data.pageSize
  442. for (var i = 0; i < data.list.length; i++) {
  443. data.list[i].no = data.list[i].productSn + '_' + (no + i + 1)
  444. data.list[i].salesNums = 1
  445. data.list[i].currentQty = data.list[i].currentQty || 0
  446. 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
  447. data.list[i].productOrigCode = data.list[i].productOrigCode ? data.list[i].productOrigCode.trim() : ''
  448. }
  449. if (!params.vinCode) {
  450. _this.vinInfoData = null
  451. }
  452. } else {
  453. data = {
  454. list: [],
  455. pageNo: 1,
  456. pageSize: 10
  457. }
  458. }
  459. _this.disabled = false
  460. console.log(data)
  461. return data
  462. })
  463. },
  464. // vin change
  465. vinCodeChange (e) {
  466. if (e.target.value.length == 17) {
  467. supperCodeByVin({ vin: e.target.value }).then(res => {
  468. if (res.status == 200) {
  469. this.queryParam.productCodeList = res.data
  470. } else {
  471. this.queryParam.productCodeList = undefined
  472. }
  473. })
  474. } else {
  475. this.queryParam.productCodeList = undefined
  476. }
  477. },
  478. // 双击列表
  479. handleClickRow (record) {
  480. this.handleAdd(record)
  481. },
  482. // 重置
  483. resetSearchForm (flag) {
  484. this.queryParam.productCode = ''
  485. this.queryParam.productName = ''
  486. this.queryParam.productOrigCode = ''
  487. this.queryParam.brandSn = undefined
  488. this.queryParam.productTypeSn1 = ''
  489. this.queryParam.productTypeSn2 = ''
  490. this.queryParam.productTypeSn3 = ''
  491. this.queryParam.warehouseSn = undefined
  492. this.queryParam.productCodeList = undefined
  493. this.queryParam.existStockFlag = undefined
  494. this.queryParam.vinCode = ''
  495. this.productType = []
  496. this.$refs.ruleForm.resetFields()
  497. this.vinInfoData = null
  498. this.showTable = false
  499. if (!flag) {
  500. this.$refs.table.refresh(true)
  501. }
  502. },
  503. pageInit (buyerSn, priceType, salesBillSn) {
  504. this.priceType = priceType || ''
  505. this.buyerSn = buyerSn || ''
  506. this.queryParam.salesBillSn = salesBillSn || ''
  507. },
  508. // 刷新当前页面
  509. resetCurForm () {
  510. this.$refs.table.refresh()
  511. },
  512. // 清空数据
  513. clearTable () {
  514. this.vinInfoData = null
  515. this.$refs.ruleForm.resetFields()
  516. this.$refs.table.clearTable()
  517. },
  518. filterOption (input, option) {
  519. return (
  520. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  521. )
  522. },
  523. // 选择配件
  524. handleAdd (row) {
  525. const _this = this
  526. if (row.lastSalePrice && (row.price < row.salePrice)) {
  527. _this.$confirm({
  528. title: '提示',
  529. content: '售价低于定价,是否仍继续添加?',
  530. centered: true,
  531. closable: true,
  532. onOk () {
  533. _this.$emit('add', row)
  534. }
  535. })
  536. } else {
  537. _this.$emit('add', row)
  538. }
  539. },
  540. // 销售记录
  541. handleDetail (row) {
  542. this.$emit('viewRecord', row)
  543. },
  544. uploadFun () {
  545. document.getElementById('filed').click()
  546. },
  547. filePreview (e) {
  548. const _this = this
  549. var files = e.target.files[0]
  550. const formData = new FormData()
  551. formData.append('savePathType', 'local')
  552. formData.append('file', files)
  553. this.vinLoading = true
  554. vinCodeParse(formData).then(res => {
  555. if (res.type == 'application/json') {
  556. var reader = new FileReader()
  557. reader.addEventListener('loadend', function () {
  558. const obj = JSON.parse(reader.result)
  559. if (obj.status == 200) {
  560. _this.queryParam.vinCode = obj.data || ''
  561. // 移除表单项的校验结果
  562. _this.$refs.ruleForm.clearValidate('vinCode')
  563. } else {
  564. _this.$notification.error({
  565. message: '提示',
  566. description: obj.message
  567. })
  568. }
  569. _this.vinLoading = false
  570. document.getElementById('filed').value = ''
  571. })
  572. reader.readAsText(res)
  573. } else {
  574. _this.vinLoading = false
  575. }
  576. })
  577. },
  578. // 仓库
  579. getWarehouse () {
  580. warehouseAllList({ wasteFlag: 0 }).then(res => {
  581. if (res.status == 200) {
  582. this.warehouseList = res.data
  583. } else {
  584. this.warehouseList = []
  585. }
  586. })
  587. },
  588. // 产品分类 change
  589. changeProductType (val, opt) {
  590. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  591. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  592. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  593. },
  594. // 查看是否有库存、
  595. handleHasQty (val) {
  596. this.queryParam.existStockFlag = val
  597. },
  598. onClose () {
  599. this.resetSearchForm(true)
  600. this.$emit('close')
  601. },
  602. setTableH () {
  603. this.$nextTick(() => {
  604. const searchBoxH = this.$refs.searchBox.offsetHeight
  605. this.tableHeight = window.innerHeight - searchBoxH - 245
  606. })
  607. }
  608. }
  609. }
  610. </script>
  611. <style lang="less">
  612. .chooseProduct-drawer {
  613. .ant-drawer-header{
  614. padding: 13px 20px;
  615. }
  616. .ant-drawer-body {
  617. padding: 15px 20px;
  618. height: calc(100% - 50px);
  619. display: flex;
  620. flex-direction: column;
  621. overflow: auto;
  622. > div {
  623. height: 100%;
  624. }
  625. .noStock{
  626. text-decoration: line-through;
  627. color: red;
  628. }
  629. .ant-input-number-sm input{
  630. text-align: center;
  631. }
  632. .vinInfo-box{
  633. display: flex;
  634. justify-content: space-between;
  635. align-items: center;
  636. .vinInfo-error{
  637. color: red;
  638. }
  639. }
  640. }
  641. }
  642. </style>