reserve_form.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941
  1. <template>
  2. <div class="detail-container">
  3. <el-page-header @back="goBack" :content="listItem ? '编辑' : '新增'"></el-page-header>
  4. <div class="main-title">
  5. <div class="title">预留单信息</div>
  6. </div>
  7. <el-form ref="mainForm" :model="mainForm" label-width="70px" size="small" label-position="left">
  8. <el-row :gutter="20">
  9. <el-col :xs="24" :sm="12" :lg="6">
  10. <el-form-item label="单据编号" prop="orderNum">
  11. <el-input v-model="mainForm.orderNum" placeholder="系统自动生成" disabled></el-input>
  12. </el-form-item>
  13. </el-col>
  14. <el-col :xs="24" :sm="12" :lg="6" style="height: 51px">
  15. <el-form-item label="单据日期" prop="orderDate">
  16. <el-date-picker
  17. v-model="mainForm.orderDate"
  18. disabled
  19. type="date"
  20. value-format="yyyy-MM-dd"
  21. style="width: 100%"
  22. placeholder="系统自动生成"
  23. >
  24. </el-date-picker>
  25. </el-form-item>
  26. </el-col>
  27. <el-col :xs="24" :sm="12" :lg="6">
  28. <el-form-item label="制单人" prop="createMan">
  29. <el-input v-model="mainForm.createMan" placeholder="请输入制单人" disabled></el-input>
  30. </el-form-item>
  31. </el-col>
  32. <el-col :xs="24" :sm="12" :lg="6" style="height: 51px">
  33. <el-form-item label="制单日期" prop="createDate">
  34. <el-date-picker
  35. v-model="mainForm.createDate"
  36. disabled
  37. type="datetime"
  38. value-format="yyyy-MM-dd HH:mm:ss"
  39. style="width: 100%"
  40. placeholder="选择日期"
  41. >
  42. </el-date-picker>
  43. </el-form-item>
  44. </el-col>
  45. <el-col :xs="24" :sm="24" :lg="24">
  46. <el-form-item label="备注" prop="remark">
  47. <el-input v-model="mainForm.remark" placeholder="请输入备注"></el-input>
  48. </el-form-item>
  49. </el-col>
  50. </el-row>
  51. </el-form>
  52. <div style="margin-top: 20px">
  53. <el-button type="primary" size="small" icon="el-icon-plus" @click="openDialog" v-if="!listItem"
  54. >添加引用</el-button
  55. >
  56. <el-button
  57. type="danger"
  58. size="small"
  59. icon="el-icon-minus"
  60. @click="deleteGoods"
  61. :disabled="tableSelection.length < 1"
  62. v-if="!listItem"
  63. >批量删除</el-button
  64. >
  65. <el-button
  66. size="small"
  67. icon="el-icon-edit"
  68. @click="batchChangeNum"
  69. :disabled="tableSelection.length < 1"
  70. v-if="!listItem"
  71. >批量设置预留数量</el-button
  72. >
  73. </div>
  74. <div class="table" style="margin-top: 20px">
  75. <el-table
  76. :data="goodsList"
  77. element-loading-text="Loading"
  78. border
  79. fit
  80. highlight-current-row
  81. stripe
  82. max-height="400"
  83. @selection-change="tableSelectionChange"
  84. >
  85. <el-table-column align="center" type="selection" width="55"></el-table-column>
  86. <el-table-column
  87. align="center"
  88. label="销售订单号"
  89. prop="mainOrderId"
  90. min-width="140"
  91. show-overflow-tooltip
  92. ></el-table-column>
  93. <el-table-column align="center" label="订单日期" prop="orderTime" min-width="120" show-overflow-tooltip>
  94. <template slot-scope="scope">
  95. {{ scope.row.orderTime | dateToDayFilter }}
  96. </template>
  97. </el-table-column>
  98. <el-table-column align="center" label="经销商编码" prop="customerNumber" min-width="120" show-overflow-tooltip>
  99. <template slot-scope="scope">
  100. <div v-if="scope.row.orderId || listItem">{{ scope.row.customerNumber }}</div>
  101. <el-select
  102. v-else
  103. v-model="scope.row.customerNumber"
  104. placeholder="选择经销商"
  105. size="small"
  106. filterable
  107. remote
  108. clearable
  109. :remote-method="e => checkDealerList(e, 1)"
  110. @change="changeDealer(scope.$index)"
  111. >
  112. <el-option v-for="item in dealerList" :key="item.number" :label="item.number" :value="item.number">
  113. <span>{{ item.number }}</span>
  114. <span style="color: #8492a6; font-size: 13px; margin-left: 6px">{{ item.name }}</span>
  115. </el-option>
  116. </el-select>
  117. </template>
  118. </el-table-column>
  119. <el-table-column align="center" label="经销商名称" prop="customerName" min-width="160" show-overflow-tooltip>
  120. <template slot-scope="scope">
  121. <div v-if="scope.row.orderId || listItem">{{ scope.row.customerName }}</div>
  122. <el-select
  123. v-else
  124. v-model="scope.row.customerNumber"
  125. placeholder="选择经销商"
  126. size="small"
  127. filterable
  128. remote
  129. clearable
  130. :remote-method="e => checkDealerList(e, 2)"
  131. @change="changeDealer(scope.$index)"
  132. >
  133. <el-option v-for="item in dealerList" :key="item.number" :label="item.name" :value="item.number">
  134. <span>{{ item.number }}</span>
  135. <span style="color: #8492a6; font-size: 13px; margin-left: 6px">{{ item.name }}</span>
  136. </el-option>
  137. </el-select>
  138. </template>
  139. </el-table-column>
  140. <el-table-column align="center" label="物料编码" prop="materialCode" min-width="140" show-overflow-tooltip>
  141. <template slot-scope="scope">
  142. <div v-if="scope.row.orderId || listItem">{{ scope.row.materialCode }}</div>
  143. <el-select
  144. v-else
  145. v-model="scope.row.materialCode"
  146. placeholder="选择产品"
  147. size="small"
  148. filterable
  149. remote
  150. clearable
  151. :remote-method="e => checkMaterialList(e, 1)"
  152. @change="changeMaterial(scope.$index)"
  153. >
  154. <el-option v-for="item in materialList" :key="item.number" :label="item.number" :value="item.number">
  155. <span>{{ item.number }}</span>
  156. <span style="color: #8492a6; font-size: 13px; margin-left: 6px">{{ item.name }}</span>
  157. </el-option>
  158. </el-select>
  159. </template>
  160. </el-table-column>
  161. <el-table-column
  162. align="center"
  163. label="产品编码"
  164. prop="materialOldNumber"
  165. min-width="120"
  166. show-overflow-tooltip
  167. ></el-table-column>
  168. <el-table-column
  169. align="center"
  170. label="产品名称"
  171. prop="materialName"
  172. min-width="160"
  173. show-overflow-tooltip
  174. ></el-table-column>
  175. <el-table-column align="center" label="规格型号" prop="specification" min-width="200" show-overflow-tooltip>
  176. <template slot-scope="scope">
  177. <div v-if="scope.row.orderId || listItem">{{ scope.row.specification }}</div>
  178. <el-select
  179. v-else
  180. v-model="scope.row.materialCode"
  181. placeholder="选择规格型号"
  182. size="small"
  183. filterable
  184. remote
  185. clearable
  186. :remote-method="e => checkMaterialList(e, 2)"
  187. @change="changeMaterial(scope.$index)"
  188. >
  189. <el-option
  190. v-for="item in materialList"
  191. :key="item.number"
  192. :label="item.specification"
  193. :value="item.number"
  194. >
  195. <span>{{ item.number }}</span>
  196. <span style="color: #8492a6; font-size: 13px; margin-left: 6px">{{ item.specification }}</span>
  197. </el-option>
  198. </el-select>
  199. </template>
  200. </el-table-column>
  201. <el-table-column
  202. align="center"
  203. label="单位"
  204. prop="unit"
  205. min-width="100"
  206. show-overflow-tooltip
  207. ></el-table-column>
  208. <!-- <el-table-column align="center" label="原预留数量" prop="oldNum" min-width="100" show-overflow-tooltip></el-table-column> -->
  209. <el-table-column align="center" label="预留数量" prop="reservedNum" min-width="100" show-overflow-tooltip>
  210. <template slot-scope="scope">
  211. <el-input v-model="scope.row.reservedNum" size="small"></el-input>
  212. </template>
  213. </el-table-column>
  214. <el-table-column
  215. align="center"
  216. label="订单数量"
  217. prop="qty"
  218. min-width="100"
  219. show-overflow-tooltip
  220. ></el-table-column>
  221. <el-table-column
  222. align="center"
  223. label="可用数量"
  224. prop="openNumber"
  225. min-width="100"
  226. show-overflow-tooltip
  227. ></el-table-column>
  228. <el-table-column
  229. align="center"
  230. label="可预留数量"
  231. prop="refundableQty"
  232. min-width="100"
  233. show-overflow-tooltip
  234. ></el-table-column>
  235. <el-table-column align="center" label="预留仓库" prop="correspondId" min-width="160" show-overflow-tooltip>
  236. <template slot-scope="scope">
  237. <el-select
  238. v-model="scope.row.correspondId"
  239. placeholder="选择预留仓库"
  240. size="small"
  241. clearable
  242. @change="changeWarehouse(scope.$index)"
  243. >
  244. <el-option
  245. :label="item.name"
  246. :value="item.id"
  247. v-for="(item, index) in scope.row.warehouseList"
  248. :key="index"
  249. ></el-option>
  250. </el-select>
  251. </template>
  252. </el-table-column>
  253. <el-table-column
  254. align="center"
  255. label="备注"
  256. prop="reservedRemark"
  257. min-width="160"
  258. show-overflow-tooltip
  259. ></el-table-column>
  260. <el-table-column align="center" label="状态" prop="status" min-width="100" show-overflow-tooltip>
  261. <template slot-scope="scope">
  262. {{ scope.row.status ? '执行中' : '已关闭' }}
  263. </template>
  264. </el-table-column>
  265. <el-table-column align="center" label="操作" width="100" fixed="right">
  266. <template slot-scope="scope">
  267. <el-button type="text" @click="deleteItem(scope.$index)" v-if="!listItem">删除</el-button>
  268. <el-button type="text" @click="changeItem(scope.$index, 0)" v-if="listItem && scope.row.status === 1"
  269. >关闭</el-button
  270. >
  271. <el-button type="text" @click="changeItem(scope.$index, 1)" v-if="listItem && scope.row.status === 0"
  272. >开启</el-button
  273. >
  274. </template>
  275. </el-table-column>
  276. </el-table>
  277. <div class="add" v-if="!listItem">
  278. <el-button type="text" icon="el-icon-plus" @click="addGoods">添加行</el-button>
  279. </div>
  280. </div>
  281. <div class="page-footer">
  282. <div class="footer">
  283. <el-button type="primary" @click="clickSubmitForm">保 存</el-button>
  284. <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px">
  285. <el-button slot="reference">关 闭</el-button>
  286. </el-popconfirm>
  287. </div>
  288. </div>
  289. <el-dialog title="添加引用" :visible.sync="isShowDialog" width="80%">
  290. <el-form ref="screenForm" :model="screenForm" size="small" label-position="left">
  291. <el-row :gutter="20">
  292. <el-col :xs="12" :sm="6" :lg="4">
  293. <el-form-item prop="jxsNum">
  294. <el-input v-model="screenForm.jxsNum" placeholder="经销商编码"></el-input>
  295. </el-form-item>
  296. </el-col>
  297. <el-col :xs="12" :sm="6" :lg="4">
  298. <el-form-item prop="jxsName">
  299. <el-input v-model="screenForm.jxsName" placeholder="经销商名称"></el-input>
  300. </el-form-item>
  301. </el-col>
  302. <el-col :xs="12" :sm="6" :lg="4">
  303. <el-form-item prop="type">
  304. <el-select v-model="screenForm.type" placeholder="产品大类" style="width: 100%">
  305. <el-option
  306. v-for="item in typeList"
  307. :key="item.dictValue"
  308. :label="item.dictValue"
  309. :value="item.dictValue"
  310. ></el-option>
  311. </el-select>
  312. </el-form-item>
  313. </el-col>
  314. <el-col :xs="12" :sm="6" :lg="4">
  315. <el-form-item prop="goodsNum">
  316. <el-input v-model="screenForm.goodsNum" placeholder="物料编码"></el-input>
  317. </el-form-item>
  318. </el-col>
  319. <el-col :xs="12" :sm="6" :lg="4">
  320. <el-form-item prop="goodsCode">
  321. <el-input v-model="screenForm.goodsCode" placeholder="产品编码"></el-input>
  322. </el-form-item>
  323. </el-col>
  324. <el-col :xs="12" :sm="6" :lg="4">
  325. <el-form-item prop="goodsName">
  326. <el-input v-model="screenForm.goodsName" placeholder="产品名称"></el-input>
  327. </el-form-item>
  328. </el-col>
  329. <el-col :xs="12" :sm="6" :lg="4">
  330. <el-form-item prop="model">
  331. <el-input v-model="screenForm.model" placeholder="规格型号"></el-input>
  332. </el-form-item>
  333. </el-col>
  334. <el-col :xs="12" :sm="6" :lg="4">
  335. <el-form-item prop="orderType">
  336. <el-select v-model="screenForm.orderType" placeholder="订单类型" style="width: 100%">
  337. <el-option
  338. v-for="item in orderTypeList"
  339. :key="item.value"
  340. :label="item.label"
  341. :value="item.value"
  342. ></el-option>
  343. </el-select>
  344. </el-form-item>
  345. </el-col>
  346. <el-col :xs="12" :sm="6" :lg="4">
  347. <el-form-item prop="saleNum">
  348. <el-input v-model="screenForm.saleNum" placeholder="销售订单号"></el-input>
  349. </el-form-item>
  350. </el-col>
  351. <el-col :xs="12" :sm="18" :lg="12" class="tr">
  352. <el-form-item label="">
  353. <el-button size="small" @click="resetScreenForm">清空</el-button>
  354. <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
  355. </el-form-item>
  356. </el-col>
  357. </el-row>
  358. </el-form>
  359. <div class="table">
  360. <el-table
  361. :data="dialogGoodsList"
  362. element-loading-text="Loading"
  363. border
  364. fit
  365. highlight-current-row
  366. stripe
  367. height="400"
  368. @selection-change="dialogSelectionChange"
  369. >
  370. <el-table-column align="center" type="selection" width="55" :selectable="checkboxSelect"></el-table-column>
  371. <el-table-column
  372. align="center"
  373. label="经销商编码"
  374. prop="customerNumber"
  375. min-width="120"
  376. show-overflow-tooltip
  377. ></el-table-column>
  378. <el-table-column
  379. align="center"
  380. label="经销商名称"
  381. prop="customerName"
  382. min-width="160"
  383. show-overflow-tooltip
  384. ></el-table-column>
  385. <el-table-column align="center" label="订单日期" prop="orderTime" min-width="120" show-overflow-tooltip>
  386. <template slot-scope="scope">
  387. {{ scope.row.orderTime | dateToDayFilter }}
  388. </template>
  389. </el-table-column>
  390. <el-table-column align="center" label="订单类型" prop="orderType" min-width="100" show-overflow-tooltip>
  391. <template slot-scope="scope">
  392. {{ scope.row.orderType | orderTypeFilter }}
  393. </template>
  394. </el-table-column>
  395. <el-table-column
  396. align="center"
  397. label="订单号"
  398. prop="mainOrderId"
  399. min-width="180"
  400. show-overflow-tooltip
  401. ></el-table-column>
  402. <el-table-column
  403. align="center"
  404. label="销售类型"
  405. prop="saleTypeName"
  406. min-width="100"
  407. show-overflow-tooltip
  408. ></el-table-column>
  409. <el-table-column
  410. align="center"
  411. label="物料编码"
  412. prop="materialCode"
  413. min-width="120"
  414. show-overflow-tooltip
  415. ></el-table-column>
  416. <el-table-column
  417. align="center"
  418. label="产品编码"
  419. prop="materialOldNumber"
  420. min-width="120"
  421. show-overflow-tooltip
  422. ></el-table-column>
  423. <el-table-column
  424. align="center"
  425. label="产品名称"
  426. prop="materialName"
  427. min-width="160"
  428. show-overflow-tooltip
  429. ></el-table-column>
  430. <el-table-column
  431. align="center"
  432. label="规格型号"
  433. prop="specification"
  434. min-width="160"
  435. show-overflow-tooltip
  436. ></el-table-column>
  437. <el-table-column
  438. align="center"
  439. label="单位"
  440. prop="unit"
  441. min-width="100"
  442. show-overflow-tooltip
  443. ></el-table-column>
  444. <el-table-column
  445. align="center"
  446. label="订单数量"
  447. prop="qty"
  448. min-width="100"
  449. show-overflow-tooltip
  450. ></el-table-column>
  451. <el-table-column
  452. align="center"
  453. label="可预留数量"
  454. prop="refundableQty"
  455. min-width="100"
  456. show-overflow-tooltip
  457. ></el-table-column>
  458. </el-table>
  459. <div class="pagination clearfix" style="margin-top: 10px">
  460. <div class="fr">
  461. <el-pagination
  462. @current-change="handleTableCurrentChange"
  463. :current-page="currentPage"
  464. :page-size="10"
  465. background
  466. layout="prev, pager, next"
  467. :total="listTotal"
  468. >
  469. </el-pagination>
  470. </div>
  471. </div>
  472. </div>
  473. <span slot="footer" class="dialog-footer">
  474. <el-button @click="closeDialog">取 消</el-button>
  475. <el-button type="primary" @click="submitAddGoods">确 定</el-button>
  476. </span>
  477. </el-dialog>
  478. </div>
  479. </template>
  480. <script>
  481. import {
  482. getDetail,
  483. getGoodsList,
  484. addData,
  485. editData,
  486. checkDealerList,
  487. checkMaterialList,
  488. getWarehouseList,
  489. getListStock
  490. } from '@/api/supply/reserve'
  491. import { getDictList } from '@/api/common'
  492. let that
  493. export default {
  494. name: 'ReserveForm',
  495. componentName: 'ReserveForm',
  496. props: ['listItem'],
  497. filters: {
  498. orderTypeFilter(val) {
  499. let obj = that.orderTypeFilterList.find(o => o.value == val)
  500. return obj ? obj.label : ''
  501. }
  502. },
  503. data() {
  504. return {
  505. mainForm: {
  506. orderNum: '',
  507. orderDate: '',
  508. createMan: '',
  509. createDate: '',
  510. remark: ''
  511. },
  512. goodsList: [],
  513. tableSelection: [],
  514. typeList: [],
  515. orderTypeList: [
  516. { label: '商用工程单', value: 'TRADE' },
  517. { label: '家用工程单', value: 'HOME' },
  518. { label: '零售单', value: 'RETAIL' },
  519. { label: '销售政策单', value: 'RETAIL_POLICY' },
  520. { label: '置换单', value: 'PERMU' }
  521. ],
  522. orderTypeFilterList: [
  523. { label: '商用工程单', value: 'TRADE' },
  524. { label: '家用工程单', value: 'HOME' },
  525. { label: '零售单', value: 'RETAIL' },
  526. { label: '销售政策单', value: 'RETAIL_POLICY' },
  527. { label: '置换单', value: 'PERMU_HOME' },
  528. { label: '置换单', value: 'PERMU_TRADE' },
  529. { label: '置换单', value: 'PERMU_RETAIL' },
  530. { label: '置换单', value: 'PERMU_RETAIL_POLICY' }
  531. ],
  532. isShowDialog: false,
  533. screenForm: {
  534. jxsNum: '',
  535. jxsName: '',
  536. type: '',
  537. goodsNum: '',
  538. goodsCode: '',
  539. goodsName: '',
  540. model: '',
  541. orderType: '',
  542. saleNum: ''
  543. },
  544. currentPage: 1,
  545. listTotal: 0,
  546. dialogGoodsList: [],
  547. dialogSelection: [],
  548. dealerList: [],
  549. materialList: [],
  550. warehouseList: []
  551. }
  552. },
  553. beforeCreate() {
  554. that = this
  555. },
  556. async created() {
  557. // await this.getWarehouseList();
  558. // await this.getListStock()
  559. if (this.listItem) {
  560. this.getDetail()
  561. } else {
  562. this.mainForm.createMan = JSON.parse(localStorage.getItem('supply_user')).nickName
  563. this.mainForm.createDate = this.getDate()
  564. }
  565. },
  566. methods: {
  567. getDate() {
  568. var date = new Date()
  569. var seperator1 = '-'
  570. var year = date.getFullYear()
  571. var month = date.getMonth() + 1
  572. var strDate = date.getDate()
  573. if (month >= 1 && month <= 9) {
  574. month = '0' + month
  575. }
  576. if (strDate >= 0 && strDate <= 9) {
  577. strDate = '0' + strDate
  578. }
  579. var currentdate = year + seperator1 + month + seperator1 + strDate
  580. return currentdate
  581. },
  582. getDictList() {
  583. getDictList({ sysDictEnum: 'PRODUCT_TYPE' }).then(res => {
  584. this.typeList = res.data
  585. })
  586. },
  587. // 获取仓库列表
  588. async getWarehouseList() {
  589. const res = await getWarehouseList({
  590. pageNum: 1,
  591. pageSize: -1
  592. })
  593. this.warehouseList = res.data.records
  594. },
  595. // 返回列表
  596. goBack() {
  597. this.$emit('backListFormDetail')
  598. },
  599. // 获取详情
  600. getDetail() {
  601. getDetail({ id: this.listItem.id }).then(res => {
  602. let data = res.data
  603. this.mainForm.orderNum = data.id
  604. this.mainForm.orderDate = data.orderTime
  605. this.mainForm.createMan = data.createBy
  606. this.mainForm.createDate = data.createTime
  607. this.mainForm.remark = data.remark
  608. data.reservedOrderItems.forEach(async item => {
  609. item.warehouseList = await this.getListStock(item.customerId)
  610. })
  611. this.goodsList = data.reservedOrderItems
  612. })
  613. },
  614. // 获取商品列表
  615. getGoodsList() {
  616. getGoodsList({
  617. pageNum: this.currentPage,
  618. pageSize: 10,
  619. customerNumber: this.screenForm.jxsNum,
  620. customerName: this.screenForm.jxsName,
  621. mainName: this.screenForm.type,
  622. materialCode: this.screenForm.goodsNum,
  623. materialOldNumber: this.screenForm.goodsCode,
  624. materialName: this.screenForm.goodsName,
  625. specification: this.screenForm.model,
  626. orderType: this.screenForm.orderType,
  627. orderId: this.screenForm.saleNum
  628. }).then(res => {
  629. res.data.records.forEach(item => {
  630. item.status = 1
  631. item.reservedStatus = 1
  632. })
  633. let oldGoodsList = this.goodsList
  634. let newGoodsList = res.data.records
  635. for (let i = 0; i < oldGoodsList.length; i++) {
  636. let oldItem = oldGoodsList[i]
  637. for (let j = 0; j < newGoodsList.length; j++) {
  638. let newItem = newGoodsList[j]
  639. if (newItem.orderId === oldItem.orderId) {
  640. newGoodsList[j].selected = true
  641. break
  642. }
  643. }
  644. }
  645. this.dialogGoodsList = newGoodsList
  646. this.listTotal = res.data.total
  647. })
  648. },
  649. // 查询重复值并禁选
  650. checkboxSelect(row, rowIndex) {
  651. if (row.selected) {
  652. return false // 禁用
  653. } else {
  654. return true // 不禁用
  655. }
  656. },
  657. // 点击 选择商品
  658. openDialog() {
  659. this.isShowDialog = true
  660. this.getDictList()
  661. this.getGoodsList()
  662. },
  663. // 提交筛选表单
  664. submitScreenForm() {
  665. this.currentPage = 1
  666. this.getGoodsList()
  667. },
  668. // 重置筛选表单
  669. resetScreenForm() {
  670. this.$nextTick(()=>{
  671. this.$refs.screenForm.resetFields()
  672. })
  673. this.currentPage = 1
  674. this.dialogGoodsList = []
  675. this.getGoodsList()
  676. },
  677. // 更改列表当前页
  678. handleTableCurrentChange(val) {
  679. if (this.dialogSelection.length > 0) {
  680. return this.$errorMsg('已选择产品不可切换')
  681. }
  682. this.currentPage = val
  683. this.getGoodsList()
  684. },
  685. // 关闭 弹窗
  686. closeDialog() {
  687. this.$nextTick(()=>{
  688. this.$refs.screenForm.resetFields()
  689. })
  690. this.isShowDialog = false
  691. },
  692. // 列表选择
  693. dialogSelectionChange(val) {
  694. this.dialogSelection = val
  695. },
  696. async getListStock(customerId) {
  697. const result = await new Promise((resolve, reject) => {
  698. getListStock({
  699. pageNum: 1,
  700. pageSize: -1,
  701. customerId: customerId
  702. })
  703. .then(res => {
  704. resolve(res.data.records)
  705. })
  706. .catch(res => {
  707. resolve([])
  708. })
  709. })
  710. return result
  711. // this.warehouseList = res.data.records;
  712. },
  713. // 确定 添加产品
  714. submitAddGoods() {
  715. this.dialogSelection.forEach(async item => {
  716. item.warehouseList = await this.getListStock(item.customerId)
  717. })
  718. this.goodsList = this.goodsList.concat(this.dialogSelection)
  719. this.isShowDialog = false
  720. this.dialogGoodsList = []
  721. },
  722. // 删除产品
  723. deleteItem(index) {
  724. this.goodsList.splice(index, 1)
  725. },
  726. // 修改状态
  727. changeItem(index, status) {
  728. this.goodsList[index].status = status
  729. },
  730. tableSelectionChange(val) {
  731. this.tableSelection = val
  732. },
  733. // 批量删除
  734. deleteGoods() {
  735. let goodsList = this.goodsList
  736. let tableSelection = this.tableSelection
  737. for (let i = 0; i < goodsList.length; i++) {
  738. for (let j = 0; j < tableSelection.length; j++) {
  739. if (tableSelection[j].orderId == goodsList[i].orderId) {
  740. this.goodsList.splice(i, 1)
  741. }
  742. }
  743. }
  744. },
  745. // 批量修改数量
  746. batchChangeNum() {
  747. this.$prompt('请输入预留数量', '批量设置', {
  748. confirmButtonText: '确定',
  749. cancelButtonText: '取消',
  750. inputValidator: function (value) {
  751. if (!value) return '请输入预留数量'
  752. }
  753. })
  754. .then(({ value }) => {
  755. this.tableSelection.forEach(item => {
  756. item.reservedNum = value
  757. })
  758. })
  759. .catch(() => {})
  760. },
  761. // 添加产品
  762. addGoods() {
  763. this.goodsList.push({
  764. reservedStatus: 2,
  765. status: 1,
  766. warehouseList: []
  767. })
  768. },
  769. // 查询经销商列表
  770. checkDealerList(query, type) {
  771. checkDealerList({
  772. pageNum: 1,
  773. pageSize: 100,
  774. number: type == 1 ? query : '',
  775. name: type == 2 ? query : ''
  776. }).then(res => {
  777. this.dealerList = res.data || []
  778. })
  779. },
  780. // 更改经销商
  781. async changeDealer(index) {
  782. console.log(444, index, this.goodsList, this.goodsList[index].customerNumber)
  783. if (this.goodsList[index].customerNumber) {
  784. let obj = this.dealerList.find(o => o.number == this.goodsList[index].customerNumber)
  785. this.goodsList[index].customerName = obj.name
  786. this.goodsList[index].customerId = obj.id
  787. this.goodsList[index].warehouseList = await this.getListStock(obj.id)
  788. } else {
  789. this.goodsList[index].customerName = ''
  790. this.goodsList[index].customerId = ''
  791. this.goodsList[index].warehouseList = []
  792. }
  793. },
  794. // 查询产品
  795. checkMaterialList(query, type) {
  796. checkMaterialList({
  797. pageNum: 1,
  798. pageSize: 100,
  799. number: type == 1 ? query : '',
  800. specification: type == 2 ? query : ''
  801. }).then(res => {
  802. this.materialList = res.data.records || []
  803. })
  804. },
  805. // 更改产品
  806. changeMaterial(index) {
  807. if (this.goodsList[index].materialCode) {
  808. let obj = this.materialList.find(o => o.number == this.goodsList[index].materialCode)
  809. this.goodsList[index].materialName = obj.name
  810. this.goodsList[index].materialId = obj.id
  811. this.goodsList[index].materialOldNumber = obj.oldNumber
  812. this.goodsList[index].specification = obj.specification
  813. this.goodsList[index].unit = obj.baseUnitId
  814. } else {
  815. this.goodsList[index].materialName = ''
  816. this.goodsList[index].materialId = ''
  817. this.goodsList[index].materialOldNumber = ''
  818. this.goodsList[index].specification = ''
  819. this.goodsList[index].unit = ''
  820. }
  821. },
  822. // 修改仓库
  823. changeWarehouse(index) {
  824. if (this.goodsList[index].correspondId) {
  825. let obj = this.goodsList[index].warehouseList.find(o => o.id == this.goodsList[index].correspondId)
  826. this.goodsList[index].correspondName = obj.name
  827. } else {
  828. this.goodsList[index].correspondName = ''
  829. }
  830. },
  831. // 提交
  832. clickSubmitForm() {
  833. this.$refs.mainForm.validate(valid => {
  834. if (valid) {
  835. for (let i = 0; i < this.goodsList.length; i++) {
  836. if (!this.goodsList[i].correspondId) {
  837. this.$errorMsg('请选择预留仓库')
  838. return
  839. }
  840. }
  841. let params = {
  842. // orderTime: this.mainForm.orderDate + ' 00:00:00',
  843. remark: this.mainForm.remark,
  844. reservedOrderItems: this.goodsList
  845. }
  846. if (this.listItem) {
  847. params.id = this.listItem.id
  848. editData(params).then(res => {
  849. this.$successMsg('编辑成功')
  850. this.goBack()
  851. this.$parent.getList()
  852. })
  853. } else {
  854. addData(params).then(res => {
  855. this.$successMsg('添加成功')
  856. this.goBack()
  857. this.$parent.getList()
  858. })
  859. }
  860. }
  861. })
  862. }
  863. }
  864. }
  865. </script>
  866. <style scoped lang="scss">
  867. .detail-container {
  868. width: 100%;
  869. height: 100%;
  870. }
  871. .main-title {
  872. display: flex;
  873. justify-content: space-between;
  874. align-items: center;
  875. margin-top: 20px;
  876. height: 60px;
  877. border-bottom: 1px solid #dcdfe6;
  878. margin-bottom: 20px;
  879. .title {
  880. font-size: 16px;
  881. font-weight: 600;
  882. padding-left: 10px;
  883. }
  884. }
  885. .add {
  886. display: flex;
  887. align-items: center;
  888. justify-content: center;
  889. border: 1px solid #ebeef5;
  890. border-top: none;
  891. height: 50px;
  892. }
  893. </style>