reserve_form.vue 32 KB

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