displace_list.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. <template>
  2. <div class="app-container">
  3. <div class="main-top">
  4. <div class="title">选择置换方式</div>
  5. <el-radio-group v-model="type" @change="changeType">
  6. <!-- <el-radio :label="1">订单置换</el-radio> -->
  7. <el-radio :label="2">批量置换</el-radio>
  8. </el-radio-group>
  9. </div>
  10. <div class="main-title">
  11. <div class="title">被置换产品信息</div>
  12. <div>
  13. <el-button size="mini" type="primary" @click="openBeiGoodsDialog">选择机型</el-button>
  14. </div>
  15. </div>
  16. <div class="table">
  17. <el-table :data="beiGoodsList" border fit highlight-current-row stripe>
  18. <el-table-column align="left" label="物料编码" prop="number" min-width="160" show-overflow-tooltip></el-table-column>
  19. <el-table-column align="left" label="产品编码" prop="oldNumber" min-width="160" show-overflow-tooltip></el-table-column>
  20. <el-table-column align="left" label="产品名称" prop="name" min-width="160" show-overflow-tooltip></el-table-column>
  21. <el-table-column align="left" label="规格型号" prop="specification" min-width="350" show-overflow-tooltip></el-table-column>
  22. <el-table-column align="left" label="单位" prop="baseUnitId" min-width="100" show-overflow-tooltip></el-table-column>
  23. <el-table-column align="center" label="操作" min-width="100" fixed="right">
  24. <template slot-scope="scope">
  25. <el-button type="text" @click="deleteBeiGoodsList(scope.$index)">删除</el-button>
  26. </template>
  27. </el-table-column>
  28. </el-table>
  29. </div>
  30. <div class="main-title">
  31. <div class="title">可置换产品信息</div>
  32. <div>
  33. <el-button size="mini" type="primary" @click="openKeGoodsDialog">选择机型</el-button>
  34. </div>
  35. </div>
  36. <div class="table">
  37. <el-table :data="keGoodsList" border fit highlight-current-row stripe>
  38. <el-table-column align="left" label="物料编码" prop="number" min-width="160" show-overflow-tooltip></el-table-column>
  39. <el-table-column align="left" label="产品编码" prop="oldNumber" min-width="160" show-overflow-tooltip></el-table-column>
  40. <el-table-column align="left" label="产品名称" prop="name" min-width="160" show-overflow-tooltip></el-table-column>
  41. <el-table-column align="left" label="规格型号" prop="specification" min-width="350" show-overflow-tooltip></el-table-column>
  42. <el-table-column align="left" label="单位" prop="baseUnitId" min-width="100" show-overflow-tooltip></el-table-column>
  43. <el-table-column align="center" label="操作" min-width="100" fixed="right">
  44. <template slot-scope="scope">
  45. <el-button type="text" @click="deleteKeGoodsList(scope.$index)">删除</el-button>
  46. </template>
  47. </el-table-column>
  48. </el-table>
  49. </div>
  50. <div class="main-title">
  51. <div class="title">被置换订单信息</div>
  52. <div>
  53. <el-button size="mini" type="primary" @click="openOrderDialog">选择置换订单</el-button>
  54. </div>
  55. </div>
  56. <div class="table">
  57. <el-table :data="orderList" border fit highlight-current-row stripe>
  58. <el-table-column align="left" label="订单号" prop="id" min-width="120" show-overflow-tooltip></el-table-column>
  59. <el-table-column align="left" label="经销商信息" prop="displaceOrderId" min-width="250" show-overflow-tooltip>
  60. <template slot-scope="scope">
  61. {{ scope.row.customerName + '(' + scope.row.customerNumber + ')' }}
  62. </template>
  63. </el-table-column>
  64. <el-table-column align="center" label="被置换机型" prop="displaceOrderId" min-width="160" show-overflow-tooltip>
  65. <el-table-column align="left" label="销售类型" prop="saleTypeName" min-width="100" show-overflow-tooltip></el-table-column>
  66. <el-table-column align="left" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
  67. <el-table-column align="left" label="规格型号" prop="specification" min-width="250" show-overflow-tooltip></el-table-column>
  68. <el-table-column align="right" label="单价" prop="price" min-width="100" show-overflow-tooltip></el-table-column>
  69. <el-table-column align="right" label="可被置换数量" prop="refundableQty" min-width="100" show-overflow-tooltip></el-table-column>
  70. <el-table-column align="left" label="返利类型" prop="rebateWalletName" min-width="100" show-overflow-tooltip></el-table-column>
  71. <el-table-column align="right" label="使用返利金额" prop="payRebateAmount" min-width="100" show-overflow-tooltip></el-table-column>
  72. <el-table-column align="right" label="格力折扣" prop="totalDiscAmount" min-width="100" show-overflow-tooltip></el-table-column>
  73. <el-table-column align="left" label="现金钱包" prop="walletName" min-width="100" show-overflow-tooltip></el-table-column>
  74. <el-table-column align="right" label="实付金额" prop="payAmount" min-width="100" show-overflow-tooltip></el-table-column>
  75. </el-table-column>
  76. <el-table-column align="center" label="置换机型" prop="displaceOrderId" min-width="160" show-overflow-tooltip>
  77. <el-table-column align="left" label="销售类型" prop="saleTypeName" min-width="160" show-overflow-tooltip></el-table-column>
  78. <el-table-column align="left" label="产品名称" prop="ke_materialName" min-width="160" show-overflow-tooltip></el-table-column>
  79. <el-table-column align="left" label="规格型号" prop="ke_specification" min-width="350" show-overflow-tooltip></el-table-column>
  80. <el-table-column align="right" label="单价" prop="price" min-width="100" show-overflow-tooltip></el-table-column>
  81. <el-table-column align="right" label="置换数量" prop="ke_refundableQty" min-width="100" show-overflow-tooltip>
  82. <template slot-scope="scope">
  83. <el-input v-model="scope.row.ke_refundableQty" size="mini" type="number"></el-input>
  84. </template>
  85. </el-table-column>
  86. <el-table-column align="left" label="返利类型" prop="rebateWalletName" min-width="100" show-overflow-tooltip></el-table-column>
  87. <el-table-column align="right" label="使用返利金额" prop="payRebateAmount" min-width="100" show-overflow-tooltip></el-table-column>
  88. <el-table-column align="right" label="格力折扣" prop="totalDiscAmount" min-width="100" show-overflow-tooltip></el-table-column>
  89. <el-table-column align="left" label="现金钱包" prop="walletName" min-width="100" show-overflow-tooltip></el-table-column>
  90. <el-table-column align="right" label="实付金额" prop="payAmount" min-width="100" show-overflow-tooltip>
  91. <template slot-scope="scope">
  92. {{(scope.row.price * scope.row.ke_refundableQty) - (scope.row.payRebateAmount * scope.row.ke_refundableQty) - scope.row.totalDiscAmount}}
  93. </template>
  94. </el-table-column>
  95. </el-table-column>
  96. <el-table-column align="center" label="操作" min-width="100" fixed="right">
  97. <template slot-scope="scope">
  98. <el-button type="text" @click="deleteOrderList(scope.$index)">删除</el-button>
  99. </template>
  100. </el-table-column>
  101. </el-table>
  102. </div>
  103. <div class="page-footer">
  104. <div class="footer">
  105. <el-button type="primary" @click="submitForm">提交置换</el-button>
  106. <el-popconfirm title="确定要重置吗?" @onConfirm="resetForm" style="margin-left: 10px;">
  107. <el-button slot="reference">重 置</el-button>
  108. </el-popconfirm>
  109. </div>
  110. </div>
  111. <el-dialog title="选择被置换产品" :visible.sync="beiGoodsDialog_show" width="80%">
  112. <el-form ref="beiGoodsDialog_screenForm" :model="beiGoodsDialog_screenForm" size="mini" label-position="left" label-width="80px">
  113. <el-row :gutter="20">
  114. <el-col :xs="12" :sm="6" :lg="6">
  115. <el-form-item prop="number" label="物料编码">
  116. <el-input v-model="beiGoodsDialog_screenForm.number" placeholder="请输入物料编码"></el-input>
  117. </el-form-item>
  118. </el-col>
  119. <el-col :xs="12" :sm="6" :lg="6">
  120. <el-form-item prop="oldNumber" label="产品编码">
  121. <el-input v-model="beiGoodsDialog_screenForm.oldNumber" placeholder="请输入产品编码"></el-input>
  122. </el-form-item>
  123. </el-col>
  124. <el-col :xs="12" :sm="6" :lg="6">
  125. <el-form-item prop="keyword" label="产品名称">
  126. <el-input v-model="beiGoodsDialog_screenForm.keyword" placeholder="请输入产品名称"></el-input>
  127. </el-form-item>
  128. </el-col>
  129. <el-col :xs="12" :sm="6" :lg="6">
  130. <el-form-item label="规格型号" prop="specification">
  131. <el-input v-model="beiGoodsDialog_screenForm.specification" placeholder="请输入规格型号"></el-input>
  132. </el-form-item>
  133. </el-col>
  134. <el-col :xs="24" :sm="24" :lg="24" class="tr">
  135. <el-form-item label="">
  136. <el-button @click="resetBeiGoodsDialogScreenForm">清空</el-button>
  137. <el-button type="primary" @click="submitBeiGoodsDialogScreenForm">搜索</el-button>
  138. </el-form-item>
  139. </el-col>
  140. </el-row>
  141. </el-form>
  142. <div class="table">
  143. <el-table :data="beiGoodsDialog_list" element-loading-text="Loading" border fit highlight-current-row stripe height="400">
  144. <el-table-column align="center" width="80">
  145. <template slot-scope="scope">
  146. <el-button type="primary" size="mini" @click="submitChooseBeiGoods(scope.row)" :disabled="scope.row.selected">选择</el-button>
  147. </template>
  148. </el-table-column>
  149. <el-table-column align="left" label="物料编码" prop="number" min-width="100" show-overflow-tooltip></el-table-column>
  150. <el-table-column align="left" label="产品编码" prop="oldNumber" min-width="100" show-overflow-tooltip></el-table-column>
  151. <el-table-column align="left" label="产品名称" prop="name" min-width="160" show-overflow-tooltip></el-table-column>
  152. <el-table-column align="left" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  153. <el-table-column align="left" label="是否可被置换" prop="unit" min-width="80" show-overflow-tooltip></el-table-column>
  154. </el-table>
  155. <div class="pagination clearfix" style="margin-top: 10px">
  156. <div class="fr">
  157. <el-pagination
  158. @current-change="changeBeiGoodsDialogPage"
  159. :current-page="beiGoodsDialog_currentPage"
  160. :page-size="10"
  161. background
  162. layout="prev, pager, next"
  163. :total="beiGoodsDialog_listTotal">
  164. </el-pagination>
  165. </div>
  166. </div>
  167. </div>
  168. <span slot="footer" class="dialog-footer">
  169. <el-button @click="closeBeiGoodsDialog">取 消</el-button>
  170. </span>
  171. </el-dialog>
  172. <el-dialog title="选择可置换产品" :visible.sync="keGoodsDialog_show" width="80%">
  173. <el-form ref="keGoodsDialog_screenForm" :model="keGoodsDialog_screenForm" size="mini" label-position="left" label-width="80px">
  174. <el-row :gutter="20">
  175. <el-col :xs="12" :sm="6" :lg="6">
  176. <el-form-item prop="number" label="物料编码">
  177. <el-input v-model="keGoodsDialog_screenForm.number" placeholder="请输入物料编码"></el-input>
  178. </el-form-item>
  179. </el-col>
  180. <el-col :xs="12" :sm="6" :lg="6">
  181. <el-form-item prop="oldNumber" label="产品编码">
  182. <el-input v-model="keGoodsDialog_screenForm.oldNumber" placeholder="请输入产品编码"></el-input>
  183. </el-form-item>
  184. </el-col>
  185. <el-col :xs="12" :sm="6" :lg="6">
  186. <el-form-item prop="keyword" label="产品名称">
  187. <el-input v-model="keGoodsDialog_screenForm.keyword" placeholder="请输入产品名称"></el-input>
  188. </el-form-item>
  189. </el-col>
  190. <el-col :xs="12" :sm="6" :lg="6">
  191. <el-form-item label="规格型号" prop="specification">
  192. <el-input v-model="keGoodsDialog_screenForm.specification" placeholder="请输入规格型号"></el-input>
  193. </el-form-item>
  194. </el-col>
  195. <!-- <el-col :xs="12" :sm="6" :lg="6">
  196. <el-form-item label="置换产品价格类型" prop="displaceType" label-width="125px">
  197. <el-select v-model="keGoodsDialog_screenForm.displaceType" placeholder="请选择置换产品价格类型">
  198. <el-option
  199. v-for="item in displaceTypeList"
  200. :key="item.value"
  201. :label="item.label"
  202. :value="item.value">
  203. </el-option>
  204. </el-select>
  205. </el-form-item>
  206. </el-col> -->
  207. <el-col :xs="24" :sm="24" :lg="24" class="tr">
  208. <el-form-item label="">
  209. <el-button @click="resetKeGoodsDialogScreenForm">清空</el-button>
  210. <el-button type="primary" @click="submitKeGoodsDialogScreenForm">搜索</el-button>
  211. </el-form-item>
  212. </el-col>
  213. </el-row>
  214. </el-form>
  215. <div class="table">
  216. <el-table :data="keGoodsDialog_list" element-loading-text="Loading" border fit highlight-current-row stripe height="400" @selection-change="changeKeGoodsDialogSelection" v-show="type === 1">
  217. <el-table-column align="center" type="selection" width="55" :selectable="checkboxSelect"></el-table-column>
  218. <el-table-column align="left" label="物料编码" prop="number" min-width="100" show-overflow-tooltip></el-table-column>
  219. <el-table-column align="left" label="产品编码" prop="oldNumber" min-width="100" show-overflow-tooltip></el-table-column>
  220. <el-table-column align="left" label="产品名称" prop="name" min-width="160" show-overflow-tooltip></el-table-column>
  221. <el-table-column align="left" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  222. </el-table>
  223. <el-table :data="keGoodsDialog_list" element-loading-text="Loading" border fit highlight-current-row stripe height="400" v-show="type === 2">
  224. <el-table-column align="center" width="80">
  225. <template slot-scope="scope">
  226. <el-button type="primary" size="mini" @click="submitChooseKeGoods(scope.row)" :disabled="scope.row.selected">选择</el-button>
  227. </template>
  228. </el-table-column>
  229. <el-table-column align="left" label="物料编码" prop="number" min-width="100" show-overflow-tooltip></el-table-column>
  230. <el-table-column align="left" label="产品编码" prop="oldNumber" min-width="100" show-overflow-tooltip></el-table-column>
  231. <el-table-column align="left" label="产品名称" prop="name" min-width="160" show-overflow-tooltip></el-table-column>
  232. <el-table-column align="left" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  233. </el-table>
  234. <div class="pagination clearfix" style="margin-top: 10px">
  235. <div class="fr">
  236. <el-pagination
  237. @current-change="changeKeGoodsDialogPage"
  238. :current-page="keGoodsDialog_currentPage"
  239. :page-size="10"
  240. background
  241. layout="prev, pager, next"
  242. :total="keGoodsDialog_listTotal">
  243. </el-pagination>
  244. </div>
  245. </div>
  246. </div>
  247. <span slot="footer" class="dialog-footer">
  248. <el-button @click="closeKeGoodsDialog">取 消</el-button>
  249. <el-button type="primary" @click="submitChooseKeGoods" v-if="type === 1">确 定</el-button>
  250. </span>
  251. </el-dialog>
  252. <el-dialog title="选择被置换订单" :visible.sync="orderDialog_show" width="80%">
  253. <el-form ref="orderDialog_screenForm" :model="orderDialog_screenForm" size="mini" label-position="left" label-width="85px">
  254. <el-row :gutter="20">
  255. <el-col :xs="12" :sm="6" :lg="6">
  256. <el-form-item prop="id" label="订单号">
  257. <el-input v-model="orderDialog_screenForm.id" placeholder="请输入订单号"></el-input>
  258. </el-form-item>
  259. </el-col>
  260. <el-col :xs="12" :sm="6" :lg="6">
  261. <el-form-item prop="customerName" label="经销商名称">
  262. <el-input v-model="orderDialog_screenForm.customerName" placeholder="请输入经销商名称"></el-input>
  263. </el-form-item>
  264. </el-col>
  265. <el-col :xs="12" :sm="6" :lg="6">
  266. <el-form-item prop="customerNumber" label="经销商编号">
  267. <el-input v-model="orderDialog_screenForm.customerNumber" placeholder="请输入经销商编号"></el-input>
  268. </el-form-item>
  269. </el-col>
  270. <el-col :xs="12" :sm="6" :lg="6" class="tr">
  271. <el-form-item label="">
  272. <el-button @click="resetOrderDialogScreenForm">清空</el-button>
  273. <el-button type="primary" @click="submitOrderDialogScreenForm">搜索</el-button>
  274. </el-form-item>
  275. </el-col>
  276. </el-row>
  277. </el-form>
  278. <div class="table">
  279. <el-table :data="orderDialog_list" element-loading-text="Loading" border fit highlight-current-row stripe height="400" v-show="type === 1">
  280. <el-table-column align="center" width="80">
  281. <template slot-scope="scope">
  282. <el-button type="primary" size="mini" @click="submitChooseOrder(scope.row)" :disabled="scope.row.selected">选择</el-button>
  283. </template>
  284. </el-table-column>
  285. <el-table-column align="left" label="订单号" prop="id" min-width="120" show-overflow-tooltip></el-table-column>
  286. <el-table-column align="left" label="直调状态" prop="directTransferStatusName" min-width="100" show-overflow-tooltip></el-table-column>
  287. <el-table-column align="left" label="经销商信息" prop="materialName" min-width="250" show-overflow-tooltip>
  288. <template slot-scope="scope">
  289. {{ scope.row.customerName + '(' + scope.row.customerNumber + ')' }}
  290. </template>
  291. </el-table-column>
  292. <el-table-column align="left" label="销售类型" prop="saleTypeName" min-width="100" show-overflow-tooltip></el-table-column>
  293. <el-table-column align="left" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
  294. <el-table-column align="left" label="规格型号" prop="specification" min-width="250" show-overflow-tooltip></el-table-column>
  295. <el-table-column align="left" label="可被置换数量" prop="refundableQty" min-width="100" show-overflow-tooltip></el-table-column>
  296. </el-table>
  297. <el-table :data="orderDialog_list" element-loading-text="Loading" border fit highlight-current-row stripe height="400" @selection-change="changeOrderDialogSelection" v-show="type === 2">
  298. <el-table-column align="center" type="selection" width="55" :selectable="checkboxSelect" v-if="type === 2"></el-table-column>
  299. <el-table-column align="left" label="订单号" prop="id" min-width="120" show-overflow-tooltip></el-table-column>
  300. <el-table-column align="left" label="直调状态" prop="directTransferStatusName" min-width="100" show-overflow-tooltip></el-table-column>
  301. <el-table-column align="left" label="经销商信息" prop="materialName" min-width="250" show-overflow-tooltip>
  302. <template slot-scope="scope">
  303. {{ scope.row.customerName + '(' + scope.row.customerNumber + ')' }}
  304. </template>
  305. </el-table-column>
  306. <el-table-column align="left" label="销售类型" prop="saleTypeName" min-width="100" show-overflow-tooltip></el-table-column>
  307. <el-table-column align="left" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
  308. <el-table-column align="left" label="规格型号" prop="specification" min-width="250" show-overflow-tooltip></el-table-column>
  309. <el-table-column align="left" label="可被置换数量" prop="refundableQty" min-width="100" show-overflow-tooltip></el-table-column>
  310. </el-table>
  311. <div class="pagination clearfix" style="margin-top: 10px">
  312. <div class="fr">
  313. <el-pagination
  314. @current-change="changeOrderDialogPage"
  315. :current-page="orderDialog_currentPage"
  316. :page-size="10"
  317. background
  318. layout="prev, pager, next"
  319. :total="orderDialog_listTotal">
  320. </el-pagination>
  321. </div>
  322. </div>
  323. </div>
  324. <span slot="footer" class="dialog-footer">
  325. <el-button @click="closeOrderDialog">取 消</el-button>
  326. <el-button type="primary" @click="submitChooseOrder" v-if="type === 2">确 定</el-button>
  327. </span>
  328. </el-dialog>
  329. </div>
  330. </template>
  331. <script>
  332. import { getGoodsList, getOrderList, addDisplace } from "@/api/supply/displace";
  333. export default {
  334. data() {
  335. return {
  336. // 主表单信息
  337. type: 2,
  338. beiGoodsList: [], // 被置换产品列表
  339. keGoodsList: [], // 可置换产品列表
  340. orderList: [], // 被置换订单列表
  341. // 被置换产品弹窗信息
  342. beiGoodsDialog_show: false,
  343. beiGoodsDialog_screenForm: {
  344. number: '',
  345. oldNumber: '',
  346. name: '',
  347. specification: '',
  348. },
  349. beiGoodsDialog_list: [],
  350. beiGoodsDialog_currentPage: 1,
  351. beiGoodsDialog_listTotal: 0,
  352. // 可置换产品弹窗信息
  353. keGoodsDialog_show: false,
  354. keGoodsDialog_screenForm: {
  355. number: '',
  356. oldNumber: '',
  357. name: '',
  358. specification: '',
  359. },
  360. keGoodsDialog_list: [],
  361. keGoodsDialog_selection: [],
  362. keGoodsDialog_currentPage: 1,
  363. keGoodsDialog_listTotal: 0,
  364. // 被置换订单弹窗信息
  365. orderDialog_show: false,
  366. orderDialog_screenForm: {
  367. id: '',
  368. customerName: '',
  369. customerNumber: '',
  370. },
  371. orderDialog_list: [],
  372. orderDialog_selection: [],
  373. orderDialog_currentPage: 1,
  374. orderDialog_listTotal: 0,
  375. // 其他
  376. displaceTypeList: [
  377. {label: '基础产品价格表', value: '1'},
  378. {label: '家用产品价格表', value: '2'},
  379. {label: '商用产品价格表', value: '3'},
  380. ]
  381. }
  382. },
  383. created() {
  384. },
  385. methods: {
  386. // 切换置换类型
  387. changeType() {
  388. this.resetForm();
  389. },
  390. // 查询重复值并禁选
  391. checkboxSelect(row, rowIndex) {
  392. if (row.selected) {
  393. return false // 禁用
  394. }else{
  395. return true // 不禁用
  396. }
  397. },
  398. // 获取列表 - 被置换产品
  399. getBeiGoodsList() {
  400. getGoodsList({
  401. pageNum: this.beiGoodsDialog_currentPage,
  402. pageSize: 100,
  403. ...this.beiGoodsDialog_screenForm
  404. }).then(res => {
  405. let oldGoodsList = this.beiGoodsList;
  406. let newGoodsList = res.data.records;
  407. for(let i = 0; i < oldGoodsList.length; i++) {
  408. let oldItem = oldGoodsList[i]
  409. for(let j = 0; j < newGoodsList.length; j++) {
  410. let newItem = newGoodsList[j]
  411. if(newItem.id === oldItem.id){
  412. newGoodsList[j].selected = true;
  413. break;
  414. }
  415. }
  416. }
  417. this.beiGoodsDialog_list = newGoodsList;
  418. this.beiGoodsDialog_listTotal = res.data.total;
  419. })
  420. },
  421. // 收藏商品
  422. handleCollect(id) {
  423. if(!this.token) {
  424. return console.log('请先登录');
  425. }
  426. collectData({id}).then(res => { // api请求
  427. console.log('收藏成功', res.data);
  428. })
  429. },
  430. // 加入购物车
  431. addToCart(id) {
  432. if(!this.token) {
  433. return console.log('请先登录');
  434. }
  435. addData({id}).then(res => { // api请求
  436. console.log('加入购物车成功', res.data);
  437. })
  438. },
  439. // 立即购买
  440. bug() {
  441. if(!this.token) {
  442. return console.log('请先登录');
  443. }
  444. buyData({id}).then(res => { // api请求
  445. console.log('下单成功', res.data);
  446. wx.requestPayment({ // 支付
  447. timeStamp: '',
  448. nonceStr: '',
  449. package: '',
  450. signType: 'MD5',
  451. paySign: '',
  452. success (res) { },
  453. fail (res) { }
  454. })
  455. })
  456. },
  457. // 打开弹窗 - 被置换产品
  458. openBeiGoodsDialog() {
  459. if(this.orderList.length > 0) {
  460. return this.$errorMsg('已选择订单不可更改产品');
  461. }
  462. this.beiGoodsDialog_show = true;
  463. this.getBeiGoodsList();
  464. },
  465. // 关闭弹窗 - 被置换产品
  466. closeBeiGoodsDialog() {
  467. this.beiGoodsDialog_show = false;
  468. },
  469. // 提交筛选表单 - 被置换产品
  470. submitBeiGoodsDialogScreenForm() {
  471. this.beiGoodsDialog_currentPage = 1;
  472. this.getBeiGoodsList();
  473. },
  474. // 重置筛选表单 - 被置换产品
  475. resetBeiGoodsDialogScreenForm() {
  476. this.$refs.beiGoodsDialog_screenForm.resetFields();
  477. this.beiGoodsDialog_currentPage = 1;
  478. this.beiGoodsDialog_list = [];
  479. this.getBeiGoodsList();
  480. },
  481. // 更改列表页码 - 被置换产品
  482. changeBeiGoodsDialogPage(val) {
  483. this.beiGoodsDialog_currentPage = val;
  484. this.getBeiGoodsList();
  485. },
  486. // 确认选择产品 - 被置换产品
  487. submitChooseBeiGoods(item) {
  488. this.beiGoodsList = [item];
  489. this.closeBeiGoodsDialog();
  490. },
  491. // 删除产品 - 被置换产品
  492. deleteBeiGoodsList(index) {
  493. if(this.orderList.length > 0) {
  494. return this.$errorMsg('已选择订单不可更改产品');
  495. }
  496. this.beiGoodsList.splice(index, 1);
  497. },
  498. // 获取列表 - 可置换产品
  499. getKeGoodsList() {
  500. getGoodsList({
  501. pageNum: this.keGoodsDialog_currentPage,
  502. pageSize: 100,
  503. ...this.keGoodsDialog_screenForm
  504. }).then(res => {
  505. let oldGoodsList = this.keGoodsList;
  506. let newGoodsList = res.data.records;
  507. for(let i = 0; i < oldGoodsList.length; i++) {
  508. let oldItem = oldGoodsList[i]
  509. for(let j = 0; j < newGoodsList.length; j++) {
  510. let newItem = newGoodsList[j]
  511. if(newItem.id === oldItem.id){
  512. newGoodsList[j].selected = true;
  513. break;
  514. }
  515. }
  516. }
  517. this.keGoodsDialog_list = newGoodsList;
  518. this.keGoodsDialog_listTotal = res.data.total;
  519. })
  520. },
  521. // 打开弹窗 - 可置换产品
  522. openKeGoodsDialog() {
  523. if(this.orderList.length > 0) {
  524. return this.$errorMsg('已选择订单不可更改产品');
  525. }
  526. this.keGoodsDialog_show = true;
  527. this.getKeGoodsList();
  528. },
  529. // 关闭弹窗 - 可置换产品
  530. closeKeGoodsDialog() {
  531. this.keGoodsDialog_show = false;
  532. },
  533. // 提交筛选表单 - 可置换产品
  534. submitKeGoodsDialogScreenForm() {
  535. this.keGoodsDialog_currentPage = 1;
  536. this.getKeGoodsList();
  537. },
  538. // 重置筛选表单 - 可置换产品
  539. resetKeGoodsDialogScreenForm() {
  540. this.$refs.keGoodsDialog_screenForm.resetFields();
  541. this.keGoodsDialog_currentPage = 1;
  542. this.keGoodsDialog_list = [];
  543. this.getKeGoodsList();
  544. },
  545. // 更改列表页码 - 可置换产品
  546. changeKeGoodsDialogPage(val) {
  547. this.keGoodsDialog_currentPage = val;
  548. this.getKeGoodsList();
  549. },
  550. // 选择列 - 可置换产品
  551. changeKeGoodsDialogSelection(val) {
  552. this.keGoodsDialog_selection = val;
  553. },
  554. // 确认选择产品 - 可置换产品
  555. submitChooseKeGoods(item) {
  556. // 订单置换(多选)
  557. if(this.type === 1) {
  558. this.keGoodsList = this.keGoodsList.concat(this.keGoodsDialog_selection);
  559. }
  560. // 批量置换(单选)
  561. else {
  562. this.keGoodsList = [item];
  563. }
  564. this.closeKeGoodsDialog();
  565. },
  566. // 删除产品 - 可置换产品
  567. deleteKeGoodsList(index) {
  568. if(this.orderList.length > 0) {
  569. return this.$errorMsg('已选择订单不可更改产品');
  570. }
  571. this.keGoodsList.splice(index, 1);
  572. },
  573. // 获取列表 - 被置换订单
  574. getOrderList() {
  575. getOrderList({
  576. pageNum: this.orderDialog_currentPage,
  577. pageSize: 100,
  578. type: 2,
  579. materialOldNumber: this.beiGoodsList[0].oldNumber,
  580. ...this.orderDialog_screenForm
  581. }).then(res => {
  582. let oldGoodsList = this.orderList;
  583. let newGoodsList = res.data.records;
  584. for(let i = 0; i < oldGoodsList.length; i++) {
  585. let oldItem = oldGoodsList[i]
  586. for(let j = 0; j < newGoodsList.length; j++) {
  587. let newItem = newGoodsList[j]
  588. if(newItem.orderItemId === oldItem.orderItemId){
  589. newGoodsList[j].selected = true;
  590. break;
  591. }
  592. }
  593. }
  594. this.orderDialog_list = newGoodsList;
  595. this.orderDialog_listTotal = res.data.total;
  596. })
  597. },
  598. // 打开弹窗 - 被置换订单
  599. openOrderDialog() {
  600. if(this.beiGoodsList.length < 1) {
  601. return this.$errorMsg('请先选择被置换产品');
  602. }
  603. if(this.keGoodsList.length < 1) {
  604. return this.$errorMsg('请先选择可置换产品');
  605. }
  606. this.orderDialog_show = true;
  607. this.getOrderList();
  608. },
  609. // 关闭弹窗 - 被置换订单
  610. closeOrderDialog() {
  611. this.orderDialog_show = false;
  612. },
  613. // 提交筛选表单 - 被置换订单
  614. submitOrderDialogScreenForm() {
  615. this.orderDialog_currentPage = 1;
  616. this.getOrderList();
  617. },
  618. // 重置筛选表单 - 被置换订单
  619. resetOrderDialogScreenForm() {
  620. this.$refs.orderDialog_screenForm.resetFields();
  621. this.orderDialog_currentPage = 1;
  622. this.orderDialog_list = [];
  623. this.getOrderList();
  624. },
  625. // 更改列表页码 - 被置换订单
  626. changeOrderDialogPage(val) {
  627. this.orderDialog_currentPage = val;
  628. this.getOrderList();
  629. },
  630. // 选择列 - 被置换订单
  631. changeOrderDialogSelection(val) {
  632. this.orderDialog_selection = val;
  633. },
  634. // 确认选择产品 - 被置换订单
  635. submitChooseOrder(item) {
  636. // 订单置换(单选)
  637. if(this.type === 1) {
  638. this.orderList = [item];
  639. }
  640. // 批量置换(多选)
  641. else {
  642. let orderList = JSON.parse(JSON.stringify(this.orderDialog_selection));
  643. orderList.forEach(item => {
  644. item.ke_materialName = this.keGoodsList[0].name;
  645. item.ke_specification = this.keGoodsList[0].specification;
  646. item.ke_refundableQty = '';
  647. });
  648. this.orderList = this.orderList.concat(orderList);
  649. }
  650. this.closeOrderDialog();
  651. },
  652. // 删除产品 - 被置换订单
  653. deleteOrderList(index) {
  654. this.orderList.splice(index, 1);
  655. },
  656. // 判断是否存在被置换订单
  657. checkOrder() {
  658. if(this.orderList.length > 0) {
  659. return this.$errorMsg('已选择订单不可更改产品');
  660. }
  661. return true;
  662. },
  663. // 提交
  664. submitForm() {
  665. for(let i=0; i<this.orderList.length; i++) {
  666. if(!this.orderList[i].ke_refundableQty || this.orderList[i].ke_refundableQty < 1) {
  667. this.$errorMsg('置换数量需大于0');
  668. return;
  669. }
  670. }
  671. let params = {
  672. type: this.type,
  673. newMaterialIds: this.keGoodsList.map(item => {
  674. return item.id
  675. }),
  676. orderItems: this.orderList.map(item => {
  677. return {
  678. orderId: item.id,
  679. orderItemId: item.orderItemId,
  680. displaceQty: item.ke_refundableQty,
  681. }
  682. }),
  683. }
  684. addDisplace(params).then(res => {
  685. this.$successMsg('提交成功');
  686. this.resetForm();
  687. })
  688. },
  689. // 重置
  690. resetForm() {
  691. this.beiGoodsList = [];
  692. this.keGoodsList = [];
  693. this.orderList = [];
  694. }
  695. }
  696. }
  697. </script>
  698. <style lang="scss" scoped>
  699. .main-top {
  700. display: flex;
  701. align-items: center;
  702. height: 60px;
  703. border-bottom: 1px solid #DCDFE6;
  704. margin-bottom: 20px;
  705. .title {
  706. font-size: 16px;
  707. padding-left: 10px;
  708. font-weight: 600;
  709. }
  710. .el-radio-group {
  711. margin-left: 30px;
  712. }
  713. }
  714. </style>