retail_form.vue 33 KB

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