retail_form.vue 38 KB

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