displace_form.vue 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  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="$parent.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. {{ $parent.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. // 获取详情
  739. getDetail() {
  740. getDetail({ id: this.editId }).then(res => {
  741. const data = res.data
  742. this.mainForm.displaceOrderId = data.displaceOrderId
  743. this.mainForm.orderType = data.orderType
  744. this.mainForm.orderNo = data.orderNo
  745. this.mainForm.orderDate = data.orderDate
  746. this.mainForm.mainId = data.mainId
  747. this.mainForm.mainName = data.mainName
  748. this.mainForm.enginRecordNo = data.enginRecordNo
  749. this.mainForm.projectNo = data.projectNo
  750. this.mainForm.projectName = data.projectName
  751. this.mainForm.useUnit = data.useUnit
  752. this.mainForm.installAddress = data.installAddress
  753. this.mainForm.policyId = data.policyId
  754. this.mainForm.policyCode = data.policyCode
  755. this.mainForm.policyTitle = data.policyTitle
  756. this.mainForm.policyRemark = data.policyRemark
  757. this.mainForm.serviceId = data.serviceId
  758. this.mainForm.serviceName = data.serviceName
  759. this.mainForm.takeDeposit = data.takeDeposit
  760. this.mainForm.examineStatus = data.examineStatus
  761. this.originGoodsList = data.originItems
  762. this.goodsList = data.items
  763. })
  764. },
  765. // 原订单列表 - 打开弹窗
  766. openShareDetail() {
  767. this.isShowOriginDialog = true
  768. if (this.mainForm.examineStatus && this.originGoodsList.length > 0) {
  769. this.screenOriginForm.orderNo = this.mainForm.orderNo
  770. this.queryRefDetail()
  771. }
  772. },
  773. submitScreenOriginForm() {
  774. this.$refs['screenOriginForm'].validate(valid => {
  775. if (valid) {
  776. this.queryRefDetail()
  777. }
  778. })
  779. },
  780. queryRefDetail() {
  781. this.dialogTable_listLoading = true
  782. queryRefDetail({
  783. originOrderNo: this.screenOriginForm.orderNo
  784. })
  785. .then(res => {
  786. this.dialogTable_data = res.data
  787. this.dialogTable_dataList = this.dialogTable_data.originItems
  788. if (this.mainForm.displaceOrderId) {
  789. this.originAfterHandle(this.dialogTable_dataList)
  790. }
  791. this.dialogTable_listLoading = false
  792. })
  793. .catch(() => {
  794. this.dialogTable_listLoading = false
  795. })
  796. },
  797. originAfterHandle() {
  798. const data = this.dialogTable_dataList
  799. // 历史选中的置换数回显
  800. this.$nextTick(() => {
  801. for (let i = 0; i < data.length; i++) {
  802. this.originGoodsList.forEach(goods => {
  803. if (goods.materialId === data[i].materialId) {
  804. data[i].displaceQty = goods.displaceQty
  805. this.$refs['originOrderTable'].toggleRowSelection(data[i], true)
  806. }
  807. })
  808. }
  809. })
  810. },
  811. chooseDetail() {
  812. const tableData = this.$refs['originOrderTable'].selection
  813. if (!tableData || tableData.length === 0) {
  814. return this.$errorMsg('请选择订单明细')
  815. }
  816. for (let i = 0; i < tableData.length; i++) {
  817. if (!tableData[i].displaceQty || tableData[i].displaceQty <= 0) {
  818. return this.$errorMsg(tableData[i].materialName + ':置换数量不能少于0')
  819. }
  820. if (tableData[i].displaceQty > tableData[i].refundableQty) {
  821. return this.$errorMsg(tableData[i].materialName + ':置换数量不能大于可退单置换数 ')
  822. }
  823. }
  824. this.originGoodsList = tableData
  825. this.mainForm.orderType = this.dialogTable_data.orderType
  826. this.mainForm.orderNo = this.dialogTable_data.orderNo
  827. this.mainForm.mainId = this.dialogTable_data.mainId
  828. this.mainForm.mainName = this.dialogTable_data.mainName
  829. this.mainForm.enginRecordNo = this.dialogTable_data.enginRecordNo
  830. this.mainForm.projectNo = this.dialogTable_data.projectNo
  831. this.mainForm.projectName = this.dialogTable_data.projectName
  832. this.mainForm.useUnit = this.dialogTable_data.useUnit
  833. this.mainForm.installAddress = this.dialogTable_data.installAddress
  834. this.mainForm.policyId = this.dialogTable_data.policyId
  835. this.mainForm.policyCode = this.dialogTable_data.policyCode
  836. this.mainForm.policyTitle = this.dialogTable_data.policyTitle
  837. this.mainForm.policyRemark = this.dialogTable_data.policyRemark
  838. this.mainForm.serviceId = this.dialogTable_data.serviceId
  839. this.mainForm.serviceName = this.dialogTable_data.serviceName
  840. this.mainForm.takeDeposit = this.dialogTable_data.takeDeposit
  841. this.isShowOriginDialog = false
  842. },
  843. clickSubmitForm() {
  844. this.$refs.mainForm.validate(valid => {
  845. if (valid) {
  846. for (let i = 0; i < this.goodsList.length; i++) {
  847. if (!this.goodsList[i].qty || this.goodsList[i].qty <= 0) {
  848. this.$errorMsg(this.goodsList[i].materialName + '数量不能小于0')
  849. return
  850. }
  851. if (!this.goodsList[i].customerWalletId) {
  852. this.$errorMsg('请选择现金钱包')
  853. return
  854. }
  855. }
  856. let params = {
  857. orderDate: this.mainForm.orderDate + ' 00:00:00',
  858. orderNo: this.mainForm.orderNo,
  859. remark: this.mainForm.remark,
  860. originItems: this.originGoodsList,
  861. items: this.goodsList
  862. }
  863. if (this.listItem) {
  864. params.displaceOrderId = this.editId
  865. editData(params).then(res => {
  866. this.$successMsg('编辑成功')
  867. this.goBack()
  868. this.$parent.getList()
  869. })
  870. } else {
  871. addData(params).then(res => {
  872. this.$successMsg('添加成功')
  873. this.goBack()
  874. this.$parent.getList()
  875. })
  876. }
  877. }
  878. })
  879. },
  880. // 获取钱包列表
  881. getWalletList() {
  882. getWalletList({
  883. customerId: JSON.parse(localStorage.getItem('supply_user')).customerId,
  884. type: 'COMMONLY'
  885. }).then(res => {
  886. this.xjWalletList = res.data
  887. })
  888. getWalletList({
  889. customerId: JSON.parse(localStorage.getItem('supply_user')).customerId,
  890. type: 'REBATE'
  891. }).then(res => {
  892. this.flWalletList = res.data
  893. })
  894. },
  895. // 获取产品大类列表
  896. getDictList() {
  897. getDictList({ sysDictEnum: 'PRODUCT_TYPE' }).then(res => {
  898. this.typeList = res.data
  899. })
  900. },
  901. // 获取销售类型列表
  902. getSalesTypeList() {
  903. getTypeList({
  904. pageNum: 1,
  905. pageSize: -1
  906. }).then(res => {
  907. this.salesTypeList = res.data.records
  908. })
  909. },
  910. // 获取仓库列表
  911. getWarehouseList() {
  912. getWarehouseList({
  913. pageNum: 1,
  914. pageSize: -1
  915. }).then(res => {
  916. this.warehouseList = res.data.records
  917. })
  918. },
  919. getDate() {
  920. var date = new Date()
  921. var seperator1 = '-'
  922. var year = date.getFullYear()
  923. var month = date.getMonth() + 1
  924. var strDate = date.getDate()
  925. if (month >= 1 && month <= 9) {
  926. month = '0' + month
  927. }
  928. if (strDate >= 0 && strDate <= 9) {
  929. strDate = '0' + strDate
  930. }
  931. return year + seperator1 + month + seperator1 + strDate
  932. },
  933. // 检查库存
  934. checkStock() {
  935. if (!this.warehouseValue) {
  936. return this.$errorMsg('请选择仓库')
  937. }
  938. if (!this.goodsList) {
  939. return this.$errorMsg('请添加货品')
  940. }
  941. let ids = []
  942. this.goodsList.forEach(item => {
  943. ids.push(item.materialId)
  944. })
  945. checkStock({
  946. correspondId: this.warehouseValue,
  947. materialId: ids.join(',')
  948. }).then(res => {
  949. if (res.data) {
  950. this.goodsList.forEach((item, index) => {
  951. item.status1 = res.data[index].allStockNum
  952. item.status2 = res.data[index].stockNum
  953. })
  954. }
  955. })
  956. },
  957. // 点击 选择商品
  958. openDialog() {
  959. this.getSalesTypeList()
  960. this.getGoodsList()
  961. this.isShowDialog = true
  962. },
  963. // 关闭 弹窗
  964. closeDialog() {
  965. this.isShowDialog = false
  966. },
  967. // 左侧列表选择
  968. leftSelectionChange(val) {
  969. this.leftSelection = val
  970. },
  971. // 右侧列表选择
  972. rightSelectionChange(val) {
  973. this.rightSelection = val
  974. },
  975. // 数组去重
  976. delRepeat(arr1, arr2) {
  977. let allArr = arr1.concat(arr2) // 两个数组对象合并
  978. let newArr = [] // 存放去重后数据的新数组
  979. for (let i = 0; i < allArr.length; i++) {
  980. // 循环allArr数组对象的内容
  981. let flag = true // 建立标记,判断数据是否重复,true为不重复
  982. for (let j = 0; j < newArr.length; j++) {
  983. // 循环新数组的内容
  984. if (allArr[i].materialId == newArr[j].materialId) {
  985. // 让allArr数组对象的内容与新数组的内容作比较,相同的话,改变标记为false
  986. flag = false
  987. }
  988. }
  989. if (flag) {
  990. // 判断是否重复
  991. newArr.push(allArr[i]) // 不重复的放入新数组。 新数组的内容会继续进行上边的循环。
  992. }
  993. }
  994. return newArr
  995. },
  996. // 全部添加
  997. addAllGoods() {
  998. this.rightGoodsList = this.delRepeat(this.leftGoodsList, this.rightGoodsList)
  999. },
  1000. // 添加
  1001. addGoods() {
  1002. this.rightGoodsList = this.delRepeat(this.leftSelection, this.rightGoodsList)
  1003. },
  1004. // 删除
  1005. deleteGoods() {
  1006. let rightGoodsList = this.rightGoodsList
  1007. let rightSelection = this.rightSelection
  1008. for (let i = 0; i < rightGoodsList.length; i++) {
  1009. for (let j = 0; j < rightSelection.length; j++) {
  1010. if (rightSelection[j].materialId == rightGoodsList[i].materialId) {
  1011. this.rightGoodsList.splice(i, 1)
  1012. }
  1013. }
  1014. }
  1015. },
  1016. // 全部删除
  1017. deleteAllGoods() {
  1018. this.rightGoodsList = []
  1019. },
  1020. // 确定 添加产品
  1021. submitAddGoods() {
  1022. this.goodsList = this.delRepeat(this.rightGoodsList, this.goodsList)
  1023. this.isShowDialog = false
  1024. this.leftGoodsList = []
  1025. this.rightGoodsList = []
  1026. },
  1027. // 查询重复值并禁选
  1028. checkboxSelect(row, rowIndex) {
  1029. if (row.selected) {
  1030. return false // 禁用
  1031. } else {
  1032. return true // 不禁用
  1033. }
  1034. },
  1035. // 删除产品
  1036. deleteItem(index) {
  1037. this.goodsList.splice(index, 1)
  1038. },
  1039. // 提交筛选表单
  1040. submitScreenForm() {
  1041. this.currentPage = 1
  1042. this.getGoodsList()
  1043. },
  1044. // 重置筛选表单
  1045. resetScreenForm() {
  1046. this.$nextTick(()=>{
  1047. this.$refs.screenForm.resetFields()
  1048. })
  1049. this.currentPage = 1
  1050. this.getGoodsList()
  1051. },
  1052. // 更改列表当前页
  1053. handleTableCurrentChange(val) {
  1054. this.currentPage = val
  1055. this.getGoodsList()
  1056. },
  1057. // 修改返利钱包
  1058. changeWallet(index) {
  1059. if (this.goodsList[index].customerWalletId2) {
  1060. let obj = this.flWalletList.find(o => o.customerWalletId == this.goodsList[index].customerWalletId2)
  1061. this.goodsList[index].rebateRate = obj.rebateRate
  1062. } else {
  1063. this.goodsList[index].rebateRate = ''
  1064. }
  1065. },
  1066. status2Filter(item) {
  1067. if (item.status2 === '' || item.status2 === null || item.status2 === undefined) return '未检查'
  1068. if (item.status2 <= 0) {
  1069. return '无货'
  1070. } else if (item.status2 >= 1 && item.status2 <= 30) {
  1071. return item.status2
  1072. } else if (item.status2 >= 31 && item.status2 <= 1000) {
  1073. return '有货'
  1074. } else {
  1075. return '充足'
  1076. }
  1077. },
  1078. // 获取商品列表
  1079. getGoodsList() {
  1080. getGoodsList({
  1081. pageNum: this.currentPage,
  1082. pageSize: 10,
  1083. mainId: this.mainForm.mainId,
  1084. saleId: this.screenForm.salesType,
  1085. materialCode: this.screenForm.proNum,
  1086. materialName: this.screenForm.proName,
  1087. specification: this.screenForm.proModel,
  1088. price1: this.screenForm.price1,
  1089. price2: this.screenForm.price2
  1090. }).then(res => {
  1091. let oldGoodsList = this.goodsList
  1092. let newGoodsList = res.data.records
  1093. for (let i = 0; i < oldGoodsList.length; i++) {
  1094. let oldItem = oldGoodsList[i]
  1095. for (let j = 0; j < newGoodsList.length; j++) {
  1096. let newItem = newGoodsList[j]
  1097. if (newItem.materialId === oldItem.materialId) {
  1098. newGoodsList[j].selected = true
  1099. break
  1100. }
  1101. }
  1102. }
  1103. res.data.records.forEach(item => {
  1104. item.materialName = item.name
  1105. item.materialCode = item.number
  1106. item.saleTypeName = item.saleName
  1107. item.unit = item.baseUnit
  1108. item.price = item.batchPrice
  1109. item.tax = item.taxRate
  1110. item.isDirectTransfer = false
  1111. item.directTransferQty = ''
  1112. item.status1 = ''
  1113. item.status2 = ''
  1114. item.rebateAmount = ''
  1115. item.rebateRate = ''
  1116. item.productPriceId = item.id
  1117. })
  1118. this.leftGoodsList = res.data.records
  1119. this.listTotal = res.data.total
  1120. })
  1121. }
  1122. }
  1123. }
  1124. </script>
  1125. <style scoped lang="scss">
  1126. .detail-container {
  1127. width: 100%;
  1128. height: 100%;
  1129. }
  1130. .main-title {
  1131. display: flex;
  1132. justify-content: space-between;
  1133. align-items: center;
  1134. margin-top: 20px;
  1135. height: 60px;
  1136. border-bottom: 1px solid #dcdfe6;
  1137. margin-bottom: 20px;
  1138. .title {
  1139. font-size: 16px;
  1140. font-weight: 600;
  1141. padding-left: 10px;
  1142. }
  1143. }
  1144. .tables {
  1145. display: flex;
  1146. margin-top: 10px;
  1147. .table {
  1148. width: 45%;
  1149. }
  1150. .buttons {
  1151. display: flex;
  1152. flex-direction: column;
  1153. justify-content: center;
  1154. align-items: center;
  1155. padding: 0 10px;
  1156. button {
  1157. margin: 0;
  1158. margin-top: 10px;
  1159. }
  1160. }
  1161. }
  1162. .choose-order {
  1163. }
  1164. </style>