displace_form.vue 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209
  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="100px" size="small" label-position="left">
  8. <el-row :gutter="20">
  9. <el-col :xs="24" :sm="12" :lg="8">
  10. <el-form-item label="订单号" prop="orderNo">
  11. <div>
  12. <el-input v-model="mainForm.orderNo" placeholder="请输入订单号" disabled>
  13. <el-button slot="append" icon="el-icon-search" @click="openShareDetail" class="choose-order"
  14. >选择</el-button
  15. >
  16. </el-input>
  17. </div>
  18. </el-form-item>
  19. </el-col>
  20. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px">
  21. <el-form-item
  22. label="单据日期"
  23. prop="orderDate"
  24. :rules="{ required: true, message: '单据日期不能为空', trigger: 'blur' }"
  25. >
  26. <el-date-picker
  27. v-model="mainForm.orderDate"
  28. type="date"
  29. value-format="yyyy-MM-dd"
  30. style="width: 100%"
  31. placeholder="选择日期"
  32. >
  33. </el-date-picker>
  34. </el-form-item>
  35. </el-col>
  36. <el-col :xs="24" :sm="12" :lg="8">
  37. <el-form-item label="品类" prop="mainName">
  38. <el-input :value="mainForm.mainName" placeholder="品类" disabled></el-input>
  39. </el-form-item>
  40. </el-col>
  41. <template v-if="mainForm.policyCode">
  42. <el-col :xs="24" :sm="12" :lg="8">
  43. <el-form-item label="销售政策编号" prop="policyCode">
  44. <el-input :value="mainForm.policyCode" placeholder="销售政策编号" disabled></el-input>
  45. </el-form-item>
  46. </el-col>
  47. <el-col :xs="24" :sm="12" :lg="8">
  48. <el-form-item label="销售政策" prop="policyTitle">
  49. <el-input :value="mainForm.policyTitle" placeholder="销售政策" disabled></el-input>
  50. </el-form-item>
  51. </el-col>
  52. <el-col :xs="24" :sm="12" :lg="8">
  53. <el-form-item label="销售政策说明" prop="policyRemark">
  54. <el-input :value="mainForm.policyRemark" placeholder="销售政策说明" disabled></el-input>
  55. </el-form-item>
  56. </el-col>
  57. </template>
  58. <template v-if="mainForm.enginRecordNo">
  59. <el-col :xs="24" :sm="12" :lg="8">
  60. <el-form-item label="工程登录编号" prop="enginRecordNo">
  61. <el-input :value="mainForm.enginRecordNo" placeholder="工程登录编号" disabled></el-input>
  62. </el-form-item>
  63. </el-col>
  64. </template>
  65. <el-col :xs="24" :sm="12" :lg="8">
  66. <el-form-item label="订单类型" prop="orderType">
  67. <el-input :value="findOrderType(mainForm.orderType)" placeholder="订单类型" disabled></el-input>
  68. </el-form-item>
  69. </el-col>
  70. <el-col :xs="24" :sm="12" :lg="8">
  71. <el-form-item label="业务员" prop="serviceName">
  72. <el-input :value="mainForm.serviceName" placeholder="业务员" disabled></el-input>
  73. </el-form-item>
  74. </el-col>
  75. <el-col :xs="24" :sm="24" :lg="24">
  76. <el-form-item label="备注" prop="remark">
  77. <el-input v-model="mainForm.remark" placeholder="请输入备注"></el-input>
  78. </el-form-item>
  79. </el-col>
  80. </el-row>
  81. </el-form>
  82. <div class="main-title">
  83. <div class="title">原订单货品信息</div>
  84. </div>
  85. <div class="table" style="margin-top: 20px">
  86. <el-table
  87. :data="originGoodsList"
  88. element-loading-text="Loading"
  89. border
  90. fit
  91. highlight-current-row
  92. stripe
  93. max-height="400"
  94. >
  95. <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
  96. <el-table-column
  97. align="center"
  98. label="销售类型"
  99. prop="saleTypeName"
  100. min-width="160"
  101. show-overflow-tooltip
  102. ></el-table-column>
  103. <el-table-column
  104. align="center"
  105. label="产品编码"
  106. prop="materialNumber"
  107. min-width="160"
  108. show-overflow-tooltip
  109. ></el-table-column>
  110. <el-table-column
  111. align="center"
  112. label="产品旧编码"
  113. prop="materialOldNumber"
  114. min-width="160"
  115. show-overflow-tooltip
  116. ></el-table-column>
  117. <el-table-column
  118. align="center"
  119. label="产品名称"
  120. prop="materialName"
  121. min-width="160"
  122. show-overflow-tooltip
  123. ></el-table-column>
  124. <el-table-column
  125. align="center"
  126. label="规格型号"
  127. prop="specification"
  128. min-width="160"
  129. show-overflow-tooltip
  130. ></el-table-column>
  131. <el-table-column
  132. align="center"
  133. label="单位"
  134. prop="unit"
  135. min-width="160"
  136. show-overflow-tooltip
  137. ></el-table-column>
  138. <el-table-column
  139. align="center"
  140. label="单价"
  141. prop="price"
  142. min-width="160"
  143. show-overflow-tooltip
  144. ></el-table-column>
  145. <el-table-column align="center" label="数量" prop="qty" min-width="160" show-overflow-tooltip></el-table-column>
  146. <el-table-column
  147. align="center"
  148. label="订单金额"
  149. prop="totalAmount"
  150. min-width="100"
  151. show-overflow-tooltip
  152. ></el-table-column>
  153. <el-table-column
  154. align="center"
  155. label="返利类型"
  156. prop="customerWalletName2"
  157. min-width="100"
  158. show-overflow-tooltip
  159. ></el-table-column>
  160. <el-table-column
  161. align="center"
  162. label="返利金额"
  163. prop="rebateAmount"
  164. min-width="100"
  165. show-overflow-tooltip
  166. ></el-table-column>
  167. <el-table-column
  168. align="center"
  169. label="格力折扣"
  170. prop="discAmount"
  171. min-width="100"
  172. show-overflow-tooltip
  173. ></el-table-column>
  174. <el-table-column
  175. align="center"
  176. label="现金钱包"
  177. prop="customerWalletName"
  178. min-width="100"
  179. show-overflow-tooltip
  180. ></el-table-column>
  181. <el-table-column
  182. align="center"
  183. label="实付金额"
  184. prop="payAmount"
  185. min-width="100"
  186. show-overflow-tooltip
  187. ></el-table-column>
  188. <el-table-column
  189. align="center"
  190. label="原数量"
  191. prop="refundableQty"
  192. min-width="100"
  193. show-overflow-tooltip
  194. ></el-table-column>
  195. <el-table-column
  196. align="center"
  197. label="置换数量"
  198. prop="displaceQty"
  199. min-width="100"
  200. show-overflow-tooltip
  201. ></el-table-column>
  202. <el-table-column
  203. align="center"
  204. label="备注"
  205. prop="remark"
  206. min-width="100"
  207. show-overflow-tooltip
  208. ></el-table-column>
  209. <el-table-column align="center" label="税率" prop="tax" min-width="100" show-overflow-tooltip></el-table-column>
  210. </el-table>
  211. </div>
  212. <div class="main-title" v-if="mainForm.orderNo">
  213. <div class="title">置换货品信息</div>
  214. <div v-if="!listItem">
  215. <el-select v-model="warehouseValue" placeholder="请选择发货仓库" size="small" style="margin-right: 10px">
  216. <el-option
  217. :label="item.name"
  218. :value="item.id"
  219. v-for="(item, index) in warehouseList"
  220. :key="index"
  221. ></el-option>
  222. </el-select>
  223. <el-button type="primary" size="small" icon="el-icon-search" @click="checkStock">检查库存</el-button>
  224. <el-divider direction="vertical"></el-divider>
  225. <el-button type="primary" size="small" icon="el-icon-plus" @click="openDialog">添加货品</el-button>
  226. </div>
  227. </div>
  228. <div class="table" style="margin-top: 20px" v-if="mainForm.orderNo">
  229. <el-table
  230. :data="goodsList"
  231. element-loading-text="Loading"
  232. border
  233. fit
  234. highlight-current-row
  235. stripe
  236. max-height="400"
  237. >
  238. <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
  239. <el-table-column
  240. align="center"
  241. label="销售类型"
  242. prop="saleTypeName"
  243. min-width="160"
  244. show-overflow-tooltip
  245. ></el-table-column>
  246. <el-table-column
  247. align="center"
  248. label="产品编码"
  249. prop="materialNumber"
  250. min-width="160"
  251. show-overflow-tooltip
  252. ></el-table-column>
  253. <el-table-column
  254. align="center"
  255. label="产品旧编码"
  256. prop="materialOldNumber"
  257. min-width="160"
  258. show-overflow-tooltip
  259. ></el-table-column>
  260. <el-table-column
  261. align="center"
  262. label="产品名称"
  263. prop="materialName"
  264. min-width="160"
  265. show-overflow-tooltip
  266. ></el-table-column>
  267. <el-table-column
  268. align="center"
  269. label="规格型号"
  270. prop="specification"
  271. min-width="160"
  272. show-overflow-tooltip
  273. ></el-table-column>
  274. <el-table-column
  275. align="center"
  276. label="单位"
  277. prop="unit"
  278. min-width="160"
  279. show-overflow-tooltip
  280. ></el-table-column>
  281. <el-table-column
  282. align="center"
  283. label="单价"
  284. prop="price"
  285. min-width="160"
  286. show-overflow-tooltip
  287. ></el-table-column>
  288. <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip>
  289. <template slot-scope="scope">
  290. <el-input v-model="scope.row.qty" size="small"></el-input>
  291. </template>
  292. </el-table-column>
  293. <el-table-column align="center" label="订单金额" min-width="100" show-overflow-tooltip>
  294. <template slot-scope="scope">
  295. {{ scope.row.price * scope.row.qty }}
  296. </template>
  297. </el-table-column>
  298. <el-table-column align="center" label="返利类型" prop="customerWalletId2" min-width="160" show-overflow-tooltip>
  299. <template slot-scope="scope">
  300. <el-select
  301. v-model="scope.row.customerWalletId2"
  302. placeholder="选择返利类型"
  303. size="small"
  304. clearable
  305. @change="changeWallet(scope.$index)"
  306. >
  307. <el-option
  308. v-for="item in flWalletList"
  309. :key="item.customerWalletId"
  310. :label="item.name"
  311. :value="item.customerWalletId"
  312. >
  313. </el-option>
  314. </el-select>
  315. </template>
  316. </el-table-column>
  317. <el-table-column align="center" label="使用返利金额" min-width="120" show-overflow-tooltip>
  318. <template slot-scope="scope">
  319. {{ (scope.row.price * scope.row.qty * (scope.row.rebateRate * 100)) / 100 }}
  320. </template>
  321. </el-table-column>
  322. <el-table-column align="center" label="格力折扣" min-width="100" show-overflow-tooltip>
  323. <template slot-scope="scope">
  324. {{ scope.row.qty * scope.row.discAmount }}
  325. </template>
  326. </el-table-column>
  327. <el-table-column align="center" label="现金钱包" prop="customerWalletId" min-width="160" show-overflow-tooltip>
  328. <template slot-scope="scope">
  329. <el-select v-model="scope.row.customerWalletId" placeholder="选择现金钱包" size="small" clearable>
  330. <el-option
  331. v-for="item in xjWalletList"
  332. :key="item.customerWalletId"
  333. :label="item.name"
  334. :value="item.customerWalletId"
  335. >
  336. </el-option>
  337. </el-select>
  338. </template>
  339. </el-table-column>
  340. <el-table-column align="center" label="实付金额" prop="payAmount" min-width="100" show-overflow-tooltip>
  341. <template slot-scope="scope">
  342. {{
  343. (scope.row.price * scope.row.qty * 100 -
  344. ((scope.row.price * scope.row.qty * (scope.row.rebateRate * 100)) / 100) * 100 -
  345. ((scope.row.qty * (scope.row.discAmount * 100)) / 100) * 100) /
  346. 100
  347. }}
  348. </template>
  349. </el-table-column>
  350. <el-table-column align="center" label="备注" prop="remark" min-width="160">
  351. <template slot-scope="scope">
  352. <el-input v-model="scope.row.remark" size="small"></el-input>
  353. </template>
  354. </el-table-column>
  355. <el-table-column align="center" label="税率" prop="tax" min-width="100" show-overflow-tooltip></el-table-column>
  356. <el-table-column
  357. align="center"
  358. label="总仓库"
  359. prop="status1"
  360. min-width="100"
  361. show-overflow-tooltip
  362. v-if="!listItem"
  363. >
  364. <template slot-scope="scope">
  365. <div>{{ scope.row.status1 | status1Filter }}</div>
  366. </template>
  367. </el-table-column>
  368. <el-table-column
  369. align="center"
  370. label="仓库状态"
  371. prop="status2"
  372. min-width="100"
  373. show-overflow-tooltip
  374. v-if="!listItem"
  375. >
  376. <template slot-scope="scope">
  377. <div>{{ status2Filter(scope.row) }}</div>
  378. </template>
  379. </el-table-column>
  380. <el-table-column align="center" label="操作" width="100" fixed="right">
  381. <template slot-scope="scope">
  382. <el-button type="text" @click="deleteItem(scope.$index)">删除</el-button>
  383. </template>
  384. </el-table-column>
  385. </el-table>
  386. </div>
  387. <div class="page-footer">
  388. <div class="footer" :class="classObj">
  389. <el-button type="primary" @click="clickSubmitForm">保 存</el-button>
  390. <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px">
  391. <el-button slot="reference">关 闭</el-button>
  392. </el-popconfirm>
  393. </div>
  394. </div>
  395. <!-- 订单列表 -->
  396. <el-dialog title="订单列表" :visible.sync="isShowOriginDialog" width="70%" :close-on-click-modal="false">
  397. <el-form
  398. v-if="mainForm.examineStatus === ''"
  399. ref="screenOriginForm"
  400. :model="screenOriginForm"
  401. label-width="80px"
  402. size="small"
  403. >
  404. <el-row :gutter="20">
  405. <el-col :xs="24" :sm="12" :lg="8">
  406. <el-form-item
  407. label="原订单号"
  408. prop="orderNo"
  409. :rules="{ required: true, message: '原订单号不能为空', trigger: 'blur' }"
  410. >
  411. <el-input v-model="screenOriginForm.orderNo" placeholder="原订单号"></el-input>
  412. </el-form-item>
  413. </el-col>
  414. <el-col :xs="24" :sm="12" :lg="6" class="tr">
  415. <el-form-item label="">
  416. <el-button size="small" type="primary" @click="submitScreenOriginForm">搜索</el-button>
  417. </el-form-item>
  418. </el-col>
  419. </el-row>
  420. </el-form>
  421. <div class="table" style="margin: 10px 0 20px">
  422. <el-table
  423. ref="originOrderTable"
  424. v-loading="dialogTable_listLoading"
  425. :data="dialogTable_dataList"
  426. element-loading-text="Loading"
  427. tooltip-effect="dark"
  428. style="width: 100%"
  429. border
  430. max-height="270"
  431. >
  432. <el-table-column type="selection" width="55"></el-table-column>
  433. <el-table-column align="center" prop="orderType" label="订单类型" show-overflow-tooltip>
  434. <template slot-scope="scope">
  435. {{ findOrderType(dialogTable_data.orderType) }}
  436. </template>
  437. </el-table-column>
  438. <el-table-column align="center" prop="saleTypeName" label="销售类型" show-overflow-tooltip></el-table-column>
  439. <el-table-column align="center" prop="materialName" label="产品名称" show-overflow-tooltip></el-table-column>
  440. <el-table-column align="center" prop="specification" label="规格型号" show-overflow-tooltip></el-table-column>
  441. <el-table-column align="center" prop="unit" label="单位" show-overflow-tooltip></el-table-column>
  442. <el-table-column align="center" prop="qty" label="数量" show-overflow-tooltip></el-table-column>
  443. <el-table-column
  444. align="center"
  445. prop="refundableQty"
  446. label="可退单置换数"
  447. show-overflow-tooltip
  448. ></el-table-column>
  449. <el-table-column align="center" prop="displaceQty" label="退订置换数" show-overflow-tooltip>
  450. <template slot-scope="scope">
  451. <el-input v-model="scope.row.displaceQty" size="small"></el-input>
  452. </template>
  453. </el-table-column>
  454. </el-table>
  455. </div>
  456. <div slot="footer" class="dialog-footer">
  457. <el-button @click="isShowOriginDialog = false">关 闭</el-button>
  458. <el-button @click="chooseDetail">提 交</el-button>
  459. </div>
  460. </el-dialog>
  461. <el-dialog title="添加产品" :visible.sync="isShowDialog" width="80%">
  462. <el-form ref="screenForm" :model="screenForm" size="small" label-position="left">
  463. <el-row :gutter="20">
  464. <el-col :xs="12" :sm="6" :lg="6">
  465. <el-form-item prop="type">
  466. <el-select v-model="mainForm.mainId" placeholder="选择品类" style="width: 100%" disabled>
  467. <el-option
  468. v-for="item in typeList"
  469. :key="item.dictCode"
  470. :label="item.dictValue"
  471. :value="item.dictCode"
  472. ></el-option>
  473. </el-select>
  474. </el-form-item>
  475. </el-col>
  476. <el-col :xs="12" :sm="6" :lg="6">
  477. <el-form-item prop="salesType">
  478. <el-select v-model="screenForm.salesType" placeholder="选择销售类型" style="width: 100%" clearable>
  479. <el-option
  480. v-for="item in salesTypeList"
  481. :key="item.id"
  482. :label="item.saleName"
  483. :value="item.id"
  484. ></el-option>
  485. </el-select>
  486. </el-form-item>
  487. </el-col>
  488. <el-col :xs="12" :sm="6" :lg="6">
  489. <el-form-item prop="proNum">
  490. <el-input v-model="screenForm.proNum" placeholder="请输入产品编码"></el-input>
  491. </el-form-item>
  492. </el-col>
  493. <el-col :xs="12" :sm="6" :lg="6">
  494. <el-form-item prop="proName">
  495. <el-input v-model="screenForm.proName" placeholder="请输入产品名称"></el-input>
  496. </el-form-item>
  497. </el-col>
  498. <el-col :xs="12" :sm="6" :lg="6">
  499. <el-form-item prop="proModel">
  500. <el-input v-model="screenForm.proModel" placeholder="请输入产品型号"></el-input>
  501. </el-form-item>
  502. </el-col>
  503. <el-col :xs="12" :sm="6" :lg="6">
  504. <el-form-item prop="price1" style="display: flex">
  505. <el-input v-model="screenForm.price1" placeholder="请输入价格" style="width: 46%"></el-input>
  506. <span> - </span>
  507. <el-input v-model="screenForm.price2" placeholder="请输入价格" style="width: 46%"></el-input>
  508. </el-form-item>
  509. </el-col>
  510. <el-col :xs="12" :sm="12" :lg="12" class="tr">
  511. <el-form-item label="">
  512. <el-button size="small" @click="resetScreenForm">清空</el-button>
  513. <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
  514. </el-form-item>
  515. </el-col>
  516. </el-row>
  517. </el-form>
  518. <div class="tables">
  519. <div class="table">
  520. <el-table
  521. :data="leftGoodsList"
  522. element-loading-text="Loading"
  523. border
  524. fit
  525. highlight-current-row
  526. stripe
  527. height="400"
  528. @selection-change="leftSelectionChange"
  529. >
  530. <el-table-column align="center" type="selection" width="55" :selectable="checkboxSelect"></el-table-column>
  531. <el-table-column
  532. align="center"
  533. label="产品编码"
  534. prop="number"
  535. min-width="100"
  536. show-overflow-tooltip
  537. ></el-table-column>
  538. <el-table-column
  539. align="center"
  540. label="产品名称"
  541. prop="name"
  542. min-width="160"
  543. show-overflow-tooltip
  544. ></el-table-column>
  545. <el-table-column
  546. align="center"
  547. label="产品型号"
  548. prop="specification"
  549. min-width="160"
  550. show-overflow-tooltip
  551. ></el-table-column>
  552. <el-table-column
  553. align="center"
  554. label="产品价格"
  555. prop="batchPrice"
  556. min-width="80"
  557. show-overflow-tooltip
  558. ></el-table-column>
  559. </el-table>
  560. <div class="pagination clearfix" style="margin-top: 10px">
  561. <div class="fr">
  562. <el-pagination
  563. @current-change="handleTableCurrentChange"
  564. :current-page="currentPage"
  565. :page-size="10"
  566. background
  567. layout="prev, pager, next"
  568. :total="listTotal"
  569. >
  570. </el-pagination>
  571. </div>
  572. </div>
  573. </div>
  574. <div class="buttons">
  575. <el-button size="small" type="primary" @click="addAllGoods">全部添加</el-button>
  576. <el-button size="small" type="primary" @click="addGoods">添&emsp;加</el-button>
  577. <el-button size="small" type="danger" @click="deleteGoods">删&emsp;除</el-button>
  578. <el-button size="small" type="danger" @click="deleteAllGoods">全部删除</el-button>
  579. </div>
  580. <div class="table">
  581. <el-table
  582. :data="rightGoodsList"
  583. element-loading-text="Loading"
  584. border
  585. fit
  586. highlight-current-row
  587. stripe
  588. height="400"
  589. @selection-change="rightSelectionChange"
  590. >
  591. <el-table-column align="center" type="selection" width="55"></el-table-column>
  592. <el-table-column
  593. align="center"
  594. label="产品编码"
  595. prop="number"
  596. min-width="100"
  597. show-overflow-tooltip
  598. ></el-table-column>
  599. <el-table-column
  600. align="center"
  601. label="产品名称"
  602. prop="name"
  603. min-width="160"
  604. show-overflow-tooltip
  605. ></el-table-column>
  606. <el-table-column
  607. align="center"
  608. label="产品型号"
  609. prop="specification"
  610. min-width="160"
  611. show-overflow-tooltip
  612. ></el-table-column>
  613. <el-table-column
  614. align="center"
  615. label="产品价格"
  616. prop="batchPrice"
  617. min-width="80"
  618. show-overflow-tooltip
  619. ></el-table-column>
  620. </el-table>
  621. </div>
  622. </div>
  623. <span slot="footer" class="dialog-footer">
  624. <el-button @click="closeDialog">取 消</el-button>
  625. <el-button type="primary" @click="submitAddGoods">确 定</el-button>
  626. </span>
  627. </el-dialog>
  628. </div>
  629. </template>
  630. <script>
  631. import { getDetail, queryRefDetail, addData, editData } from '@/api/supply/displace'
  632. import { checkStock, getWalletList, getWarehouseList } from '@/api/supply/engin'
  633. import { getDictList, getTypeList } from '@/api/common'
  634. import { getGoodsList } from '@/api/supply/retail'
  635. export default {
  636. name: 'DisplaceForm',
  637. componentName: 'DisplaceForm',
  638. props: ['listItem'],
  639. filters: {
  640. status1Filter(val) {
  641. if (val === '' || val === null || val === undefined) return '未检查'
  642. else if (val === 0) return '无货'
  643. else if (val > 0 && val <= 30) return val
  644. else if (val > 30 && val <= 1000) return '有货'
  645. else if (val > 1000) return '充足'
  646. }
  647. },
  648. data() {
  649. return {
  650. editId: '',
  651. detailData: {},
  652. mainForm: {
  653. displaceOrderId: '',
  654. orderType: '',
  655. orderNo: '',
  656. orderDate: '',
  657. mainId: '',
  658. mainName: '',
  659. enginRecordNo: '',
  660. projectNo: '',
  661. projectName: '',
  662. useUnit: '',
  663. installAddress: '',
  664. policyId: '',
  665. policyCode: '',
  666. policyTitle: '',
  667. policyRemark: '',
  668. serviceId: '',
  669. serviceName: '',
  670. takeDeposit: '',
  671. remark: '',
  672. examineStatus: ''
  673. },
  674. isShowOriginDialog: false,
  675. isShowDialog: false,
  676. dialogTable_data: null, // 列表订单数据
  677. dialogTable_dataList: [],
  678. dialogTable_listLoading: false, // 列表加载loading
  679. screenOriginForm: {
  680. orderNo: ''
  681. },
  682. screenForm: {
  683. type: '',
  684. salesType: '',
  685. proNum: '',
  686. proName: '',
  687. proModel: '',
  688. price1: '',
  689. price2: ''
  690. },
  691. currentPage: 1,
  692. listTotal: 0,
  693. salesTypeList: [],
  694. typeList: [],
  695. goodsList: [],
  696. originGoodsList: [],
  697. warehouseList: [],
  698. warehouseValue: '',
  699. leftGoodsList: [],
  700. rightGoodsList: [],
  701. leftSelection: [],
  702. rightSelection: [],
  703. xjWalletList: [],
  704. flWalletList: []
  705. }
  706. },
  707. computed: {
  708. sidebar() {
  709. return this.$store.state.app.sidebar
  710. },
  711. classObj() {
  712. return {
  713. hideSidebar: !this.sidebar.opened,
  714. openSidebar: this.sidebar.opened
  715. }
  716. }
  717. },
  718. created() {
  719. this.getDictList()
  720. this.getWalletList()
  721. this.getSalesTypeList()
  722. this.getWarehouseList()
  723. if (this.listItem) {
  724. this.editId = this.listItem.displaceOrderId
  725. this.getDetail()
  726. } else {
  727. this.mainForm.jxsNum = JSON.parse(localStorage.getItem('supply_user')).customerNumber
  728. this.mainForm.jxsName = JSON.parse(localStorage.getItem('supply_user')).customerName
  729. this.mainForm.createMan = JSON.parse(localStorage.getItem('supply_user')).nickName
  730. this.mainForm.createDate = this.getDate()
  731. }
  732. },
  733. methods: {
  734. // 返回列表
  735. goBack() {
  736. this.$emit('backListFormDetail')
  737. },
  738. findOrderType(val) {
  739. const obj = this.orderType.find(value => value.val === val)
  740. return obj ? obj.label : ''
  741. },
  742. findExamineStatus(val) {
  743. const obj = this.examineStatus.find(value => value.val === val)
  744. return obj ? obj.label : ''
  745. },
  746. // 获取详情
  747. getDetail() {
  748. getDetail({ id: this.editId }).then(res => {
  749. const data = res.data
  750. this.mainForm.displaceOrderId = data.displaceOrderId
  751. this.mainForm.orderType = data.orderType
  752. this.mainForm.orderNo = data.orderNo
  753. this.mainForm.orderDate = data.orderDate
  754. this.mainForm.mainId = data.mainId
  755. this.mainForm.mainName = data.mainName
  756. this.mainForm.enginRecordNo = data.enginRecordNo
  757. this.mainForm.projectNo = data.projectNo
  758. this.mainForm.projectName = data.projectName
  759. this.mainForm.useUnit = data.useUnit
  760. this.mainForm.installAddress = data.installAddress
  761. this.mainForm.policyId = data.policyId
  762. this.mainForm.policyCode = data.policyCode
  763. this.mainForm.policyTitle = data.policyTitle
  764. this.mainForm.policyRemark = data.policyRemark
  765. this.mainForm.serviceId = data.serviceId
  766. this.mainForm.serviceName = data.serviceName
  767. this.mainForm.takeDeposit = data.takeDeposit
  768. this.mainForm.examineStatus = data.examineStatus
  769. this.originGoodsList = data.originItems
  770. this.goodsList = data.items
  771. })
  772. },
  773. // 原订单列表 - 打开弹窗
  774. openShareDetail() {
  775. this.isShowOriginDialog = true
  776. if (this.mainForm.examineStatus && this.originGoodsList.length > 0) {
  777. this.screenOriginForm.orderNo = this.mainForm.orderNo
  778. this.queryRefDetail()
  779. }
  780. },
  781. submitScreenOriginForm() {
  782. this.$refs['screenOriginForm'].validate(valid => {
  783. if (valid) {
  784. this.queryRefDetail()
  785. }
  786. })
  787. },
  788. queryRefDetail() {
  789. this.dialogTable_listLoading = true
  790. queryRefDetail({
  791. originOrderNo: this.screenOriginForm.orderNo
  792. })
  793. .then(res => {
  794. this.dialogTable_data = res.data
  795. this.dialogTable_dataList = this.dialogTable_data.originItems
  796. if (this.mainForm.displaceOrderId) {
  797. this.originAfterHandle(this.dialogTable_dataList)
  798. }
  799. this.dialogTable_listLoading = false
  800. })
  801. .catch(() => {
  802. this.dialogTable_listLoading = false
  803. })
  804. },
  805. originAfterHandle() {
  806. const data = this.dialogTable_dataList
  807. // 历史选中的置换数回显
  808. this.$nextTick(() => {
  809. for (let i = 0; i < data.length; i++) {
  810. this.originGoodsList.forEach(goods => {
  811. if (goods.materialId === data[i].materialId) {
  812. data[i].displaceQty = goods.displaceQty
  813. this.$refs['originOrderTable'].toggleRowSelection(data[i], true)
  814. }
  815. })
  816. }
  817. })
  818. },
  819. chooseDetail() {
  820. const tableData = this.$refs['originOrderTable'].selection
  821. if (!tableData || tableData.length === 0) {
  822. return this.$errorMsg('请选择订单明细')
  823. }
  824. for (let i = 0; i < tableData.length; i++) {
  825. if (!tableData[i].displaceQty || tableData[i].displaceQty <= 0) {
  826. return this.$errorMsg(tableData[i].materialName + ':置换数量不能少于0')
  827. }
  828. if (tableData[i].displaceQty > tableData[i].refundableQty) {
  829. return this.$errorMsg(tableData[i].materialName + ':置换数量不能大于可退单置换数 ')
  830. }
  831. }
  832. this.originGoodsList = tableData
  833. this.mainForm.orderType = this.dialogTable_data.orderType
  834. this.mainForm.orderNo = this.dialogTable_data.orderNo
  835. this.mainForm.mainId = this.dialogTable_data.mainId
  836. this.mainForm.mainName = this.dialogTable_data.mainName
  837. this.mainForm.enginRecordNo = this.dialogTable_data.enginRecordNo
  838. this.mainForm.projectNo = this.dialogTable_data.projectNo
  839. this.mainForm.projectName = this.dialogTable_data.projectName
  840. this.mainForm.useUnit = this.dialogTable_data.useUnit
  841. this.mainForm.installAddress = this.dialogTable_data.installAddress
  842. this.mainForm.policyId = this.dialogTable_data.policyId
  843. this.mainForm.policyCode = this.dialogTable_data.policyCode
  844. this.mainForm.policyTitle = this.dialogTable_data.policyTitle
  845. this.mainForm.policyRemark = this.dialogTable_data.policyRemark
  846. this.mainForm.serviceId = this.dialogTable_data.serviceId
  847. this.mainForm.serviceName = this.dialogTable_data.serviceName
  848. this.mainForm.takeDeposit = this.dialogTable_data.takeDeposit
  849. this.isShowOriginDialog = false
  850. },
  851. clickSubmitForm() {
  852. this.$refs.mainForm.validate(valid => {
  853. if (valid) {
  854. for (let i = 0; i < this.goodsList.length; i++) {
  855. if (!this.goodsList[i].qty || this.goodsList[i].qty <= 0) {
  856. this.$errorMsg(this.goodsList[i].materialName + '数量不能小于0')
  857. return
  858. }
  859. if (!this.goodsList[i].customerWalletId) {
  860. this.$errorMsg('请选择现金钱包')
  861. return
  862. }
  863. }
  864. let params = {
  865. orderDate: this.mainForm.orderDate + ' 00:00:00',
  866. orderNo: this.mainForm.orderNo,
  867. remark: this.mainForm.remark,
  868. originItems: this.originGoodsList,
  869. items: this.goodsList
  870. }
  871. if (this.listItem) {
  872. params.displaceOrderId = this.editId
  873. editData(params).then(res => {
  874. this.$successMsg('编辑成功')
  875. this.goBack()
  876. })
  877. } else {
  878. addData(params).then(res => {
  879. this.$successMsg('添加成功')
  880. this.goBack()
  881. })
  882. }
  883. }
  884. })
  885. },
  886. // 获取钱包列表
  887. getWalletList() {
  888. getWalletList({
  889. customerId: JSON.parse(localStorage.getItem('supply_user')).customerId,
  890. type: 'COMMONLY'
  891. }).then(res => {
  892. this.xjWalletList = res.data
  893. })
  894. getWalletList({
  895. customerId: JSON.parse(localStorage.getItem('supply_user')).customerId,
  896. type: 'REBATE'
  897. }).then(res => {
  898. this.flWalletList = res.data
  899. })
  900. },
  901. // 获取产品大类列表
  902. getDictList() {
  903. getDictList({ sysDictEnum: 'PRODUCT_TYPE' }).then(res => {
  904. this.typeList = res.data
  905. })
  906. },
  907. // 获取销售类型列表
  908. getSalesTypeList() {
  909. getTypeList({
  910. pageNum: 1,
  911. pageSize: -1
  912. }).then(res => {
  913. this.salesTypeList = res.data.records
  914. })
  915. },
  916. // 获取仓库列表
  917. getWarehouseList() {
  918. getWarehouseList({
  919. pageNum: 1,
  920. pageSize: -1
  921. }).then(res => {
  922. this.warehouseList = res.data.records
  923. })
  924. },
  925. getDate() {
  926. var date = new Date()
  927. var seperator1 = '-'
  928. var year = date.getFullYear()
  929. var month = date.getMonth() + 1
  930. var strDate = date.getDate()
  931. if (month >= 1 && month <= 9) {
  932. month = '0' + month
  933. }
  934. if (strDate >= 0 && strDate <= 9) {
  935. strDate = '0' + strDate
  936. }
  937. return year + seperator1 + month + seperator1 + strDate
  938. },
  939. // 检查库存
  940. checkStock() {
  941. if (!this.warehouseValue) {
  942. return this.$errorMsg('请选择仓库')
  943. }
  944. if (!this.goodsList) {
  945. return this.$errorMsg('请添加货品')
  946. }
  947. let ids = []
  948. this.goodsList.forEach(item => {
  949. ids.push(item.materialId)
  950. })
  951. checkStock({
  952. correspondId: this.warehouseValue,
  953. materialId: ids.join(',')
  954. }).then(res => {
  955. if (res.data) {
  956. this.goodsList.forEach((item, index) => {
  957. item.status1 = res.data[index].allStockNum
  958. item.status2 = res.data[index].stockNum
  959. })
  960. }
  961. })
  962. },
  963. // 点击 选择商品
  964. openDialog() {
  965. this.getSalesTypeList()
  966. this.getGoodsList()
  967. this.isShowDialog = true
  968. },
  969. // 关闭 弹窗
  970. closeDialog() {
  971. this.isShowDialog = false
  972. },
  973. // 左侧列表选择
  974. leftSelectionChange(val) {
  975. this.leftSelection = val
  976. },
  977. // 右侧列表选择
  978. rightSelectionChange(val) {
  979. this.rightSelection = val
  980. },
  981. // 数组去重
  982. delRepeat(arr1, arr2) {
  983. let allArr = arr1.concat(arr2) // 两个数组对象合并
  984. let newArr = [] // 存放去重后数据的新数组
  985. for (let i = 0; i < allArr.length; i++) {
  986. // 循环allArr数组对象的内容
  987. let flag = true // 建立标记,判断数据是否重复,true为不重复
  988. for (let j = 0; j < newArr.length; j++) {
  989. // 循环新数组的内容
  990. if (allArr[i].materialId == newArr[j].materialId) {
  991. // 让allArr数组对象的内容与新数组的内容作比较,相同的话,改变标记为false
  992. flag = false
  993. }
  994. }
  995. if (flag) {
  996. // 判断是否重复
  997. newArr.push(allArr[i]) // 不重复的放入新数组。 新数组的内容会继续进行上边的循环。
  998. }
  999. }
  1000. return newArr
  1001. },
  1002. // 全部添加
  1003. addAllGoods() {
  1004. this.rightGoodsList = this.delRepeat(this.leftGoodsList, this.rightGoodsList)
  1005. },
  1006. // 添加
  1007. addGoods() {
  1008. this.rightGoodsList = this.delRepeat(this.leftSelection, this.rightGoodsList)
  1009. },
  1010. // 删除
  1011. deleteGoods() {
  1012. let rightGoodsList = this.rightGoodsList
  1013. let rightSelection = this.rightSelection
  1014. for (let i = 0; i < rightGoodsList.length; i++) {
  1015. for (let j = 0; j < rightSelection.length; j++) {
  1016. if (rightSelection[j].materialId == rightGoodsList[i].materialId) {
  1017. this.rightGoodsList.splice(i, 1)
  1018. }
  1019. }
  1020. }
  1021. },
  1022. // 全部删除
  1023. deleteAllGoods() {
  1024. this.rightGoodsList = []
  1025. },
  1026. // 确定 添加产品
  1027. submitAddGoods() {
  1028. this.goodsList = this.delRepeat(this.rightGoodsList, this.goodsList)
  1029. this.isShowDialog = false
  1030. this.leftGoodsList = []
  1031. this.rightGoodsList = []
  1032. },
  1033. // 查询重复值并禁选
  1034. checkboxSelect(row, rowIndex) {
  1035. if (row.selected) {
  1036. return false // 禁用
  1037. } else {
  1038. return true // 不禁用
  1039. }
  1040. },
  1041. // 删除产品
  1042. deleteItem(index) {
  1043. this.goodsList.splice(index, 1)
  1044. },
  1045. // 提交筛选表单
  1046. submitScreenForm() {
  1047. this.currentPage = 1
  1048. this.getGoodsList()
  1049. },
  1050. // 重置筛选表单
  1051. resetScreenForm() {
  1052. this.$refs.screenForm.resetFields()
  1053. this.currentPage = 1
  1054. this.getGoodsList()
  1055. },
  1056. // 更改列表当前页
  1057. handleTableCurrentChange(val) {
  1058. this.currentPage = val
  1059. this.getGoodsList()
  1060. },
  1061. // 修改返利钱包
  1062. changeWallet(index) {
  1063. if (this.goodsList[index].customerWalletId2) {
  1064. let obj = this.flWalletList.find(o => o.customerWalletId == this.goodsList[index].customerWalletId2)
  1065. this.goodsList[index].rebateRate = obj.rebateRate
  1066. } else {
  1067. this.goodsList[index].rebateRate = ''
  1068. }
  1069. },
  1070. status2Filter(item) {
  1071. if (item.status2 === '' || item.status2 === null || item.status2 === undefined) return '未检查'
  1072. if (item.status2 <= 0) {
  1073. return '无货'
  1074. } else if (item.status2 >= 1 && item.status2 <= 30) {
  1075. return item.status2
  1076. } else if (item.status2 >= 31 && item.status2 <= 1000) {
  1077. return '有货'
  1078. } else {
  1079. return '充足'
  1080. }
  1081. },
  1082. // 获取商品列表
  1083. getGoodsList() {
  1084. getGoodsList({
  1085. pageNum: this.currentPage,
  1086. pageSize: 10,
  1087. mainId: this.mainForm.mainId,
  1088. saleId: this.screenForm.salesType,
  1089. materialCode: this.screenForm.proNum,
  1090. materialName: this.screenForm.proName,
  1091. specification: this.screenForm.proModel,
  1092. price1: this.screenForm.price1,
  1093. price2: this.screenForm.price2
  1094. }).then(res => {
  1095. let oldGoodsList = this.goodsList
  1096. let newGoodsList = res.data.records
  1097. for (let i = 0; i < oldGoodsList.length; i++) {
  1098. let oldItem = oldGoodsList[i]
  1099. for (let j = 0; j < newGoodsList.length; j++) {
  1100. let newItem = newGoodsList[j]
  1101. if (newItem.materialId === oldItem.materialId) {
  1102. newGoodsList[j].selected = true
  1103. break
  1104. }
  1105. }
  1106. }
  1107. res.data.records.forEach(item => {
  1108. item.materialName = item.name
  1109. item.materialCode = item.number
  1110. item.saleTypeName = item.saleName
  1111. item.unit = item.baseUnit
  1112. item.price = item.batchPrice
  1113. item.tax = item.taxRate
  1114. item.isDirectTransfer = false
  1115. item.directTransferQty = ''
  1116. item.status1 = ''
  1117. item.status2 = ''
  1118. item.rebateAmount = ''
  1119. item.rebateRate = ''
  1120. item.productPriceId = item.id
  1121. })
  1122. this.leftGoodsList = res.data.records
  1123. this.listTotal = res.data.total
  1124. })
  1125. }
  1126. }
  1127. }
  1128. </script>
  1129. <style scoped lang="scss">
  1130. .detail-container {
  1131. width: 100%;
  1132. height: 100%;
  1133. }
  1134. .main-title {
  1135. display: flex;
  1136. justify-content: space-between;
  1137. align-items: center;
  1138. margin-top: 20px;
  1139. height: 60px;
  1140. border-bottom: 1px solid #dcdfe6;
  1141. margin-bottom: 20px;
  1142. .title {
  1143. font-size: 16px;
  1144. font-weight: 600;
  1145. padding-left: 10px;
  1146. }
  1147. }
  1148. .tables {
  1149. display: flex;
  1150. margin-top: 10px;
  1151. .table {
  1152. width: 45%;
  1153. }
  1154. .buttons {
  1155. display: flex;
  1156. flex-direction: column;
  1157. justify-content: center;
  1158. align-items: center;
  1159. padding: 0 10px;
  1160. button {
  1161. margin: 0;
  1162. margin-top: 10px;
  1163. }
  1164. }
  1165. }
  1166. .choose-order {
  1167. }
  1168. </style>