retail_form.vue 36 KB

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