retail_form.vue 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696
  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 ref="mainForm" :model="mainForm" label-width="120px" size="small" label-position="right">
  8. <el-row :gutter="20">
  9. <el-col :xs="24" :sm="12" :lg="12">
  10. <el-form-item label="销售政策编号" prop="policyCode">
  11. <div style="display: flex">
  12. <el-input v-model="policyId" placeholder="销售政策编号" disabled />
  13. <el-button style="margin-left: 10px" size="small" @click="handleShow">引用</el-button>
  14. </div>
  15. </el-form-item>
  16. </el-col>
  17. <!-- <el-col :xs="24" :sm="12" :lg="8" v-else>
  18. <el-form-item label="销售政策编号" prop="policyCode">
  19. <el-input
  20. disabled
  21. v-model="mainForm.policyId"
  22. placeholder="销售政策编号"
  23. ></el-input>
  24. </el-form-item>
  25. </el-col> -->
  26. <el-col :xs="24" :sm="12" :lg="12" style="height: 51px">
  27. <el-form-item label="单据日期" prop="date">
  28. <el-date-picker v-model="mainForm.date" type="datetime" disabled style="width: 100%" placeholder="选择日期" />
  29. </el-form-item>
  30. </el-col>
  31. <el-col :xs="24" :sm="12" :lg="12">
  32. <el-form-item label="表头备注" prop="remark">
  33. <el-input v-model="mainForm.remark" placeholder="请输入表头备注" />
  34. </el-form-item>
  35. </el-col>
  36. <el-col :xs="24" :sm="12" :lg="12">
  37. <el-form-item label="文件编号" prop="fileNum">
  38. <el-input v-model="mainForm.fileNum" placeholder="请输入文件编号"></el-input>
  39. </el-form-item>
  40. </el-col>
  41. <el-col :xs="24" :sm="12" :lg="12">
  42. <el-form-item label="业务员" prop="k3ServiceName">
  43. <el-select v-model="mainForm.k3ServiceName" placeholder="选择业务员" style="width: 100%" filterable
  44. @change="handleUser">
  45. <el-option v-for="item in userList" :key="item.adminUserId" :label="item.nickName"
  46. :value="item.adminUserId" />
  47. </el-select>
  48. </el-form-item>
  49. </el-col>
  50. </el-row>
  51. </el-form>
  52. <div class="main-title">
  53. <div class="title">货品信息</div>
  54. <div>
  55. <el-select v-model="warehouseValue" placeholder="请选择发货仓库" size="small" style="margin-right: 10px">
  56. <el-option v-for="(item, index) in warehouseList" :key="index" :label="item.name" :value="item.id" />
  57. </el-select>
  58. <el-button type="primary" size="small" icon="el-icon-search" @click="checkStock">检查库存</el-button>
  59. <el-divider direction="vertical" />
  60. </div>
  61. </div>
  62. <div class="table">
  63. <el-table :data="goodsList" element-loading-text="Loading" border fit highlight-current-row stripe
  64. max-height="400">
  65. <el-table-column align="left" label="序号" type="index" width="50" />
  66. <el-table-column align="left" label="销售类型" prop="saleTypeName" min-width="100" show-overflow-tooltip />
  67. <el-table-column align="left" label="物料编码" prop="materialNumber" min-width="200" show-overflow-tooltip>
  68. <template slot-scope="scope">
  69. <CopyButton :copyText="scope.row.materialNumber ? scope.row.materialNumber : scope.row.materialCode" />
  70. <span> {{ scope.row.materialNumber ? scope.row.materialNumber : scope.row.materialCode }}</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column align="left" label="产品名称" prop="materialName" min-width="200" show-overflow-tooltip>
  74. <template slot-scope="scope">
  75. <CopyButton :copyText="scope.row.materialName" />
  76. <span> {{ scope.row.materialName }}</span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column align="left" label="规格型号" prop="specification" min-width="200" show-overflow-tooltip>
  80. <template slot-scope="scope">
  81. <CopyButton :copyText="scope.row.specification" />
  82. <span> {{ scope.row.specification }}</span>
  83. </template>
  84. </el-table-column>
  85. <el-table-column align="left" label="单位" prop="unit" min-width="100" show-overflow-tooltip />
  86. <el-table-column align="right" label="单价" prop="price" min-width="100" show-overflow-tooltip />
  87. <el-table-column align="right" label="总数量" prop="qty" min-width="100" show-overflow-tooltip>
  88. <template slot-scope="scope">
  89. <el-input class="yinput" v-model="scope.row.qty" size="small" />
  90. </template>
  91. </el-table-column>
  92. <el-table-column align="right" label="订单金额" min-width="100" show-overflow-tooltip>
  93. <template slot-scope="scope">
  94. {{ scope.row.price * scope.row.qty | numToFixed }}
  95. </template>
  96. </el-table-column>
  97. <el-table-column align="left" label="返利钱包" prop="customerWalletId2" min-width="160" show-overflow-tooltip>
  98. <template slot-scope="scope">
  99. <el-select v-model="scope.row.customerWalletId2" placeholder="选择返利钱包" clearable size="small"
  100. @remove-tag="clearWallet($event, scope.row)" @change="changeWallet($event, scope.row)">
  101. <el-option v-for="item in scope.row.rebateWallets" :key="item.customerWalletId" :label="item.name"
  102. :value="item.customerWalletId" />
  103. </el-select>
  104. </template>
  105. </el-table-column>
  106. <el-table-column align="right" label="返利金额" min-width="100" show-overflow-tooltip>
  107. <template slot-scope="scope">
  108. {{ ((scope.row.price - scope.row.discAmount) * scope.row.qty * ((scope.row.rebateRate || 0) * 100)) / 100 }}
  109. </template>
  110. </el-table-column>
  111. <el-table-column align="right" label="格力折扣" min-width="100" show-overflow-tooltip>
  112. <template slot-scope="scope">
  113. {{ scope.row.qty * scope.row.discAmount | numToFixed }}
  114. </template>
  115. </el-table-column>
  116. <el-table-column align="left" label="现金钱包" prop="customerWalletId" min-width="160" show-overflow-tooltip>
  117. <template slot-scope="scope">
  118. <el-select v-model="scope.row.customerWalletId" placeholder="选择现金钱包" clearable size="small"
  119. @change="handleWallets($event, scope.row, scope.$index)">
  120. <el-option v-for="item in scope.row.wallets" :key="item.customerWalletId" :label="item.name"
  121. :value="item.customerWalletId" />
  122. </el-select>
  123. </template>
  124. </el-table-column>
  125. <!-- <el-table-column-->
  126. <!-- align="left"-->
  127. <!-- label="业务员"-->
  128. <!-- prop="retiredQty"-->
  129. <!-- min-width="160"-->
  130. <!-- show-overflow-tooltip-->
  131. <!-- >-->
  132. <!-- <template slot-scope="scope">-->
  133. <!-- <el-select-->
  134. <!-- v-model="scope.row.serviceName"-->
  135. <!-- size="small"-->
  136. <!-- disabled-->
  137. <!-- placeholder="选择业务员"-->
  138. <!-- style="width: 100%"-->
  139. <!-- @change="handleUser2($event,scope.row)"-->
  140. <!-- >-->
  141. <!-- <el-option-->
  142. <!-- v-for="item in scope.row.userList"-->
  143. <!-- :key="item.adminUserId"-->
  144. <!-- :label="item.nickName"-->
  145. <!-- :value="item.adminUserId"-->
  146. <!-- />-->
  147. <!-- </el-select>-->
  148. <!-- </template>-->
  149. <!-- </el-table-column>-->
  150. <el-table-column align="right" label="可用返利" prop="amount" min-width="100" show-overflow-tooltip>
  151. <template slot-scope="scope">
  152. <div>{{ scope.row.amount | numToFixed }}</div>
  153. </template>
  154. </el-table-column>
  155. <el-table-column align="right" label="实付金额" prop="qty" min-width="100" show-overflow-tooltip>
  156. <template slot-scope="scope">
  157. {{ comTatol(scope.row) | numToFixed }}
  158. <!-- {{(scope.row.price - (scope.row.qty * scope.row.discAmount) -(((scope.row.price - scope.row.discAmount) * scope.row.qty * ((scope.row.rebateRate || 0) * 100)) / 100))*scope.row.qty | numToFixed }} -->
  159. <!-- {{ (((scope.row.price * scope.row.qty) * 100 - ((scope.row.price * scope.row.qty * (scope.row.rebateRate * 100)) / 100) * 100 - ((scope.row.qty * (scope.row.discAmount * 100)) / 100) * 100) / 100) | numToFixed }} -->
  160. </template>
  161. </el-table-column>
  162. <el-table-column align="left" label="是否直调" prop="isDirectTransfer" min-width="100">
  163. <template slot-scope="scope">
  164. <el-checkbox v-model="scope.row.isDirectTransfer" />
  165. </template>
  166. </el-table-column>
  167. <!-- <el-table-column
  168. align="left"
  169. label="直调数量"
  170. prop="directTransferQty"
  171. min-width="100"
  172. >
  173. <template slot-scope="scope">
  174. <el-input
  175. v-model="scope.row.directTransferQty"
  176. size="small"
  177. ></el-input>
  178. </template>
  179. </el-table-column> -->
  180. <el-table-column align="left" label="表体备注" prop="remark" min-width="160">
  181. <template slot-scope="scope">
  182. <el-input v-model="scope.row.remark" size="small" />
  183. </template>
  184. </el-table-column>
  185. <el-table-column align="right" label="税率" prop="tax" min-width="100" show-overflow-tooltip />
  186. <!-- <el-table-column-->
  187. <!-- v-if="!listItem"-->
  188. <!-- align="left"-->
  189. <!-- label="总仓库"-->
  190. <!-- prop="status1"-->
  191. <!-- min-width="100"-->
  192. <!-- show-overflow-tooltip-->
  193. <!-- >-->
  194. <!-- <template slot-scope="scope">-->
  195. <!-- <div>{{ scope.row.status1 | status1Filter }}</div>-->
  196. <!-- </template>-->
  197. <!-- </el-table-column>-->
  198. <el-table-column v-if="!listItem" align="left" label="仓库状态" prop="status2" min-width="100"
  199. show-overflow-tooltip>
  200. <template slot-scope="scope">
  201. <div>{{ status2Filter(scope.row) }}</div>
  202. </template>
  203. </el-table-column>
  204. <el-table-column align="left" label="操作" width="100" fixed="right">
  205. <template slot-scope="scope">
  206. <!-- <el-button
  207. type="text"
  208. @click="(dialogVisible = true), (cid = scope.row.id)"
  209. >修改</el-button
  210. > -->
  211. <el-button type="text" @click="deleteItem(scope.$index, scope.row.id)">删除</el-button>
  212. </template>
  213. </el-table-column>
  214. </el-table>
  215. </div>
  216. <div class="page-footer">
  217. <div class="footer" :class="classObj">
  218. <el-button type="primary" @click="clickSubmitForm">保 存</el-button>
  219. <el-popconfirm title="确定关闭吗?" style="margin-left: 10px" @onConfirm="goBack">
  220. <el-button slot="reference">关 闭</el-button>
  221. </el-popconfirm>
  222. </div>
  223. </div>
  224. <el-dialog :visible.sync="isShowDialog" width="80%" :close-on-click-modal="false" title="引用销售政策"
  225. @close="handleClose">
  226. <template>
  227. <el-form ref="screenForm" :model="screenForm" label-width="120px" label-position="left" size="small">
  228. <el-row v-if="factor.length && !dataList.length" style="margin: 0 0 20px 0;font-size: 20px;">
  229. 引用销售政策表头备注:{{ !remark ? factor[0].name : remark }} 配提比例:{{ pop }}
  230. </el-row>
  231. <el-row v-if="factor.length && !dataList.length && factor[0].remark"
  232. style="margin: 0 0 20px 0;font-size: 20px;">
  233. 备注:{{ factor[0].remark }}
  234. </el-row>
  235. <el-row :gutter="20">
  236. <el-col :xs="24" :sm="12" :lg="11">
  237. <el-form-item label="销售政策" class="myselect">
  238. <el-select
  239. v-model="screenForm.policyId" placeholder="选择销售政策" filterable :disabled="disabled"
  240. style="width: 100%" @change="handlePolicy">
  241. <el-option
  242. v-for="item in policyList"
  243. :key="item.code" :label="item.title" :value="item.code">
  244. <span>{{ item.title }}</span>
  245. <span v-if="item.policyRemark" style="margin-left:15px;color:#f00;font-size:12px">( {{ item.policyRemark }} )</span>
  246. </el-option>
  247. </el-select>
  248. </el-form-item>
  249. </el-col>
  250. <el-col :xs="24" :sm="8" :lg="11">
  251. <el-form-item label="型号">
  252. <el-input v-model="screenForm.specification" placeholder="请输入型号" />
  253. </el-form-item>
  254. </el-col>
  255. <el-col :xs="24" :sm="12" :lg="11">
  256. <el-form-item label="销售类型">
  257. <el-select v-model="screenForm.saleTypeCode" filterable placeholder="选择销售类型" style="width: 100%"
  258. clearable>
  259. <el-option v-for="item in ztypeList" :key="item.id" :label="item.saleName" :value="item.saleCode" />
  260. </el-select>
  261. </el-form-item>
  262. </el-col>
  263. <el-col :xs="24" :sm="12" :lg="11" class="tr">
  264. <!-- <el-button
  265. type="primary"
  266. size="small"
  267. @click="handlePolicyTypeList"
  268. >查询</el-button> -->
  269. <el-button type="primary" size="small" @click="handlePolicyTypeList">查询</el-button>
  270. </el-col>
  271. </el-row>
  272. </el-form>
  273. <template v-if="!dataList.length">
  274. <div v-for="(item, index) in popDataArr" :key="index">
  275. <div style="padding: 20px 0">
  276. <div v-if="index == 0">限定机型</div>
  277. <div v-else>配提机型{{ index }}</div>
  278. </div>
  279. <el-table ref="singleTable" v-loading="listLoading" class="table" :data="item"
  280. element-loading-text="Loading" max-height="500" border fit highlight-current-row stripe
  281. @select-all="handleSelectionChange($event, 1, index)"
  282. @selection-change="handleSelectionChange($event, 1, index)">
  283. <el-table-column align="left" type="selection" :selectable="selectable" width="55" />
  284. <template v-for="col in columns">
  285. <el-table-column v-if="col.num" :align="col.align" :label="col.lable" :prop="col.prop"
  286. :min-width="col.widht" show-overflow-tooltip>
  287. <template slot-scope="scope">
  288. <el-input v-model.lazy="scope.row.qty" type="number" size="small" class="yinput"
  289. @blur="blurQty(scope.row.qty, scope.row)" @input="funQty(scope.row.qty, scope.row, index)" />
  290. </template>
  291. </el-table-column>
  292. <el-table-column v-else-if="col.jie" :align="col.align" :label="col.lable" :prop="col.prop"
  293. :min-width="col.widht" show-overflow-tooltip>
  294. <template slot-scope="scope">
  295. {{ scope.row.qty * scope.row.price || 0 | numToFixed }}
  296. </template>
  297. </el-table-column>
  298. <el-table-column v-else :align="col.align" :label="col.lable" :prop="col.prop" :min-width="col.widht"
  299. show-overflow-tooltip>
  300. <template slot-scope="scope">
  301. <template v-if="col.lable == '产品名称' || col.lable == '规格型号'">
  302. <CopyButton :copyText="scope.row[col.prop]" />
  303. <span> {{ scope.row[col.prop] }}</span>
  304. </template>
  305. <template v-else>
  306. {{ scope.row[col.prop] || 0 | numToFixed }}
  307. </template>
  308. </template>
  309. </el-table-column>
  310. </template>
  311. <template #append>
  312. <div class="mybox">
  313. <el-row class="mybox-row" type="flex">
  314. <el-col style="width: 55px">合计</el-col>
  315. <el-col />
  316. <el-col />
  317. <el-col />
  318. <el-col>{{ totalArr[index].totalQty }}</el-col>
  319. <el-col>{{ totalArr[index].totalPrice | numToFixed }}</el-col>
  320. <el-col>{{ totalArr[index].totalAmount | numToFixed }}</el-col>
  321. </el-row>
  322. </div>
  323. </template>
  324. </el-table>
  325. <!-- <div style="margin: 10px 0">
  326. 分页
  327. <el-pagination
  328. @size-change="
  329. popfun['handleSizeChange' + (index + 1)]($event, index + 1)
  330. "
  331. @current-change="
  332. popfun['handleCurrentChange' + (index + 1)]($event, index + 1)
  333. "
  334. :current-page="popcun['cun' + (index + 1)]"
  335. :page-sizes="[10]"
  336. :page-size="10"
  337. layout="total, sizes, prev, pager, next, jumper"
  338. :total="poptotal['total' + (index + 1)]"
  339. >
  340. </el-pagination>
  341. </div> -->
  342. </div>
  343. <!-- <div v-if="factor.length">-->
  344. <!-- 引用销售政策说明:{{ factor.length ? factor[0].name : "" }} 配提比列:{{pop}}-->
  345. <!-- </div>-->
  346. <span slot="footer" class="dialog-footer">
  347. <el-button type="primary" @click="hanlePopData">完成</el-button>
  348. </span>
  349. </template>
  350. <template v-else>
  351. <el-table ref="singleTable" v-loading="listLoading2" class="table" :data="dataList"
  352. element-loading-text="Loading" border fit max-height="500" highlight-current-row stripe
  353. @select-all="handleSelectionChange" @selection-change="handleSelectionChange">
  354. <el-table-column align="left" type="selection" :selectable="selectable2" width="55" />
  355. <template v-for="col in columns">
  356. <el-table-column v-if="col.num" :align="col.align" :label="col.lable" :prop="col.prop"
  357. :min-width="col.widht" show-overflow-tooltip>
  358. <template slot-scope="scope">
  359. <el-input v-model.lazy="scope.row.qty" type="number" class="yinput" size="small"
  360. @blur="blurQty(scope.row.qty, scope.row)" @input="funQty(scope.row.qty, scope.row)" />
  361. </template>
  362. </el-table-column>
  363. <el-table-column v-else-if="col.jie" :align="col.align" :label="col.lable" :prop="col.prop"
  364. :min-width="col.widht" show-overflow-tooltip>
  365. <template slot-scope="scope">
  366. {{ scope.row.qty * scope.row.price || 0 | numToFixed }}
  367. </template>
  368. </el-table-column>
  369. <el-table-column v-else :align="col.align" :label="col.lable" :prop="col.prop" :min-width="col.widht"
  370. show-overflow-tooltip>
  371. <template slot-scope="scope">
  372. <template v-if="col.lable == '产品名称' || col.lable == '规格型号'">
  373. <CopyButton :copyText="scope.row[col.prop]" />
  374. <span> {{ scope.row[col.prop] }}</span>
  375. </template>
  376. <template v-else>
  377. {{ scope.row[col.prop] || 0 | numToFixed }}
  378. </template>
  379. </template>
  380. </el-table-column>
  381. </template>
  382. <template #append>
  383. <div class="mybox">
  384. <el-row class="mybox-row" type="flex">
  385. <el-col style="width: 55px;">合计</el-col>
  386. <el-col />
  387. <el-col />
  388. <el-col />
  389. <el-col>{{ totalQty }}</el-col>
  390. <el-col>{{ totalPrice | numToFixed }}</el-col>
  391. <el-col>{{ totalAmount | numToFixed }}</el-col>
  392. </el-row>
  393. </div>
  394. </template>
  395. </el-table>
  396. <!-- <div style="margin: 10px 0">
  397. <el-pagination
  398. @size-change="handleSizeChange"
  399. @current-change="handleCurrentChange"
  400. :current-page="currentPage"
  401. :page-sizes="[10]"
  402. :page-size="10"
  403. layout="total, sizes, prev, pager, next, jumper"
  404. :total="total"
  405. >
  406. </el-pagination>
  407. </div> -->
  408. <span slot="footer" class="dialog-footer">
  409. <el-button type="primary" @click="hanlePopData">完成</el-button>
  410. </span>
  411. </template>
  412. </template>
  413. </el-dialog>
  414. </div>
  415. </template>
  416. <script>
  417. import {
  418. addData,
  419. checkStock,
  420. editData,
  421. getConditionList,
  422. getDetail,
  423. getGoodsList,
  424. getMaterialTypeList,
  425. getPolicyConditionList,
  426. getpolicyList,
  427. getpolicyTypeList,
  428. getSalesTypeList,
  429. getUserList,
  430. getWalletList,
  431. getWarehouseList,
  432. policyList,
  433. typeList
  434. } from '@/api/supply/policy'
  435. import { getDictList } from '@/api/common'
  436. export default {
  437. name: 'RetailForm',
  438. componentName: 'RetailForm',
  439. filters: {
  440. status1Filter(val) {
  441. if (val === '' || val === null || val === undefined) return '未检查'
  442. else if (val === 0) return '无货'
  443. else if (val > 0 && val <= 30) return val
  444. else if (val > 30 && val <= 1000) return '有货'
  445. else if (val > 1000) return '充足'
  446. }
  447. },
  448. props: ['listItem'],
  449. data() {
  450. return {
  451. tableData: [],
  452. currentPage: 1, // 当前页码
  453. pageSize: 10, // 每页数量
  454. listTotal: 0, // 列表总数
  455. cusIndex: 0,
  456. total: 0,
  457. radio: '',
  458. pop: '',
  459. dialogVisible: false,
  460. factor: [],
  461. popArr: [],
  462. mainForm: {
  463. id: '',
  464. date: '',
  465. type: '',
  466. ztype: '',
  467. remark: '',
  468. fileNum: '',
  469. policyCode: '',
  470. policyRemark: '',
  471. policyId: '',
  472. k3ServiceId: '',
  473. k3ServiceName: ''
  474. },
  475. // mainFormRules: {
  476. // type: [{ required: true, message: "请选择品类", trigger: "change" }],
  477. // },
  478. goodsList: [],
  479. warehouseList: [],
  480. warehouseValue: '',
  481. isShowDialog: false,
  482. screenForm: {
  483. policyId: '',
  484. saleTypeCode: '',
  485. factorId: '',
  486. specification: ''
  487. },
  488. currentPage: 1,
  489. listTotal: 0,
  490. salesTypeList: [],
  491. typeList: [],
  492. ztypeList: [],
  493. leftGoodsList: [],
  494. rightGoodsList: [],
  495. leftSelection: [],
  496. rightSelection: [],
  497. policyList: [],
  498. xjWalletList: [],
  499. flWalletList: [],
  500. dataList: [],
  501. columns: [
  502. {
  503. prop: 'saleTypeName',
  504. lable: '销售类型',
  505. widht: 200,
  506. align: 'left'
  507. },
  508. {
  509. prop: 'materialName',
  510. lable: '产品名称',
  511. widht: 200,
  512. align: 'left'
  513. },
  514. {
  515. prop: 'specification',
  516. lable: '规格型号',
  517. widht: 200,
  518. align: 'left'
  519. },
  520. {
  521. prop: 'qty',
  522. lable: '数量',
  523. widht: 200,
  524. num: true,
  525. align: 'right'
  526. },
  527. {
  528. prop: 'price',
  529. lable: '单价',
  530. widht: 200,
  531. align: 'right'
  532. },
  533. {
  534. prop: 'zong',
  535. widht: 200,
  536. lable: '金额',
  537. jie: true,
  538. align: 'right'
  539. }
  540. ],
  541. listLoading: false,
  542. listLoading2: false,
  543. popDataArr: [],
  544. radioObj: {},
  545. step: 0,
  546. policyId: '',
  547. policyConditionId: '',
  548. multipleSelection: [],
  549. multipleSelections: [],
  550. multipleData: [],
  551. disabled: false,
  552. cid: '',
  553. newDataList: [],
  554. userList: [],
  555. fang: false,
  556. popfun: {},
  557. poptotal: {},
  558. popcun: {},
  559. totalQty: 0,
  560. totalPrice: 0,
  561. totalAmount: 0,
  562. totalArr: [],
  563. type: 1,
  564. newMultipleSelections: [],
  565. remark: ''
  566. }
  567. },
  568. computed: {
  569. sidebar() {
  570. // console.log(11145454);
  571. return this.$store.state.app.sidebar
  572. },
  573. classObj() {
  574. return {
  575. hideSidebar: !this.sidebar.opened,
  576. openSidebar: this.sidebar.opened
  577. }
  578. },
  579. comxjWalletList() {
  580. return (c) => {
  581. // // consloe(c, "现金钱包");
  582. const walle = []
  583. const ovalVall = c == undefined || !c.length ? [] : c
  584. for (let i = 0; i < this.xjWalletList.length; i++) {
  585. for (let j = 0; j < ovalVall.length; j++) {
  586. if (this.xjWalletList[i].walletRebateId == ovalVall[j].walletId) {
  587. walle.push(this.xjWalletList[i])
  588. }
  589. }
  590. }
  591. return walle
  592. }
  593. },
  594. comText() {
  595. return (val) => {
  596. if (this.cusIndex - 1 == 0) {
  597. const params = this.radio.split('&')
  598. return this.dataList.filter((k) => {
  599. return k.id == params[0]
  600. })[0][val]
  601. } else {
  602. const params =
  603. this.radioObj['radio' + (this.cusIndex - 1)].split('&')
  604. return this.popDataArr[this.cusIndex - 2].filter((k) => {
  605. return k.id == params[0]
  606. })[0][val]
  607. }
  608. }
  609. }
  610. // pickerOptions({ $props }) {
  611. // return {
  612. // disabledDate: (time) => {
  613. // return time.getTime() < Date.now() - 1 * 24 * 60 * 60 * 1000;
  614. // },
  615. // };
  616. // },
  617. ,
  618. comTatol() {
  619. return (row) => {
  620. return ((row.price * row.qty) - (row.qty * row.discAmount) - (((row.price - row.discAmount) * row.qty * ((row.rebateRate || 0) * 100)) / 100))
  621. }
  622. }
  623. },
  624. watch: {
  625. goodsList: {
  626. handler(newValue, oldValue) {
  627. this.goodsList = newValue
  628. },
  629. immediate: true,
  630. deep: true
  631. }
  632. },
  633. created() {
  634. this.getDictList()
  635. this.getWalletList()
  636. this.getWarehouseList()
  637. this.getTypeList()
  638. this.getUserList()
  639. if (this.listItem) {
  640. this.getDetail()
  641. }
  642. },
  643. methods: {
  644. blurQty(e, row) {
  645. if (!e) {
  646. this.$set(row, 'qty', 1)
  647. }
  648. },
  649. funQty(qty, row, index) {
  650. if (row.fang) {
  651. if (this.type == 1) {
  652. this.$set(this.totalArr, index, {
  653. totalQty: 0,
  654. totalPrice: 0,
  655. totalAmount: 0
  656. })
  657. let sum = 0
  658. for (let j = 0; j < this.multipleSelections[index].length; j++) {
  659. this.multipleSelections[index][j].fang = true
  660. sum += +this.multipleSelections[index][j].qty
  661. this.totalArr[index].totalPrice +=
  662. +this.multipleSelections[index][j].price
  663. this.totalArr[index].totalAmount +=
  664. +this.multipleSelections[index][j].price * (+qty)
  665. }
  666. this.totalArr[index].totalQty = sum
  667. } else {
  668. let sum = 0
  669. this.totalQty = this.totalPrice = this.totalAmount = 0
  670. for (let i = 0; i < this.multipleSelection.length; i++) {
  671. sum += +this.multipleSelection[i].qty
  672. this.totalPrice += +this.multipleSelection[i].price
  673. this.totalAmount +=
  674. +this.multipleSelection[i].price * (+qty)
  675. }
  676. this.totalQty += sum
  677. }
  678. }
  679. },
  680. getUserList() {
  681. getUserList({
  682. pageNum: 1,
  683. pageSize: -1,
  684. adminWebsitId: '',
  685. isCustomer: 0,
  686. roleId: '',
  687. status: true,
  688. userName: ''
  689. }).then((res) => {
  690. this.userList = res.data.records
  691. // // consloe(this.userList,'122');
  692. })
  693. },
  694. handleUser(e) {
  695. const user = this.userList.filter(k => {
  696. return k.adminUserId == e
  697. })[0]
  698. this.mainForm.k3ServiceId = user.adminUserId
  699. this.mainForm.k3ServiceName = user.nickName
  700. },
  701. handleUser2(e, row) {
  702. const user = this.userList.filter(k => {
  703. return k.adminUserId == e
  704. })[0]
  705. this.$set(row, 'serviceId', user.adminUserId)
  706. this.$set(row, 'serviceName', user.nickName)
  707. this.$set(this.mainForm, 'k3ServiceId', user.adminUserId)
  708. this.$set(this.mainForm, 'k3ServiceName', user.nickName)
  709. },
  710. // 返回列表
  711. goBack() {
  712. this.$emit('backListFormDetail')
  713. },
  714. handleWallets(e, row, index) {
  715. if (e) {
  716. const service = row.wallets.filter((k) => {
  717. return e == k.customerWalletId
  718. })[0]
  719. if (index == 0 && !this.mainForm.k3ServiceId) {
  720. this.$set(this.mainForm, 'k3ServiceId', service.serviceId)
  721. this.$set(this.mainForm, 'k3ServiceName', service.serviceName)
  722. }
  723. this.$set(row, 'serviceId', service.serviceId)
  724. this.$set(row, 'serviceName', service.serviceName)
  725. // this.$set(row,'amount',service.amount || 0)
  726. } else {
  727. console.log(index)
  728. if (index === 0) {
  729. this.$set(this.mainForm, 'k3ServiceId', '')
  730. this.$set(this.mainForm, 'k3ServiceName', '')
  731. }
  732. this.$set(row, 'serviceId', '')
  733. this.$set(row, 'serviceName', '')
  734. // this.$set(row,'amount',0 )
  735. }
  736. },
  737. // 选择销售政策获取政策条件列表
  738. async handlePolicy(e) {
  739. this.totalArr = []
  740. this.multipleSelections = []
  741. this.dataList = []
  742. this.popDataArr = []
  743. this.screenForm.saleTypeCode = ''
  744. const type = this.policyList.filter((k) => {
  745. return k.code === e
  746. })[0].type
  747. if (type == 'PROVISION') {
  748. // PROVISION 配提
  749. // 选择销售政策PolidcyId改变获取条件列表
  750. const { data } = await getPolicyConditionList({ policyId: e })
  751. this.factor = data
  752. this.pop = data[0].pop
  753. this.remark = data[0].remark || ''
  754. this.popArr = data[0].pop.split(':')
  755. if (this.policyId) {
  756. this.screenForm.policyId = this.policyId
  757. if (this.listItem) {
  758. this.policyConditionId = data[0].id
  759. }
  760. } else {
  761. this.screenForm.policyId = data[0].policyId
  762. this.policyConditionId = data[0].id
  763. }
  764. for (let i = 0; i < this.popArr.length; i++) {
  765. await this.getConditionList(this.policyConditionId, i + 1)
  766. }
  767. } else {
  768. // LIMIT 限量
  769. this.getMaterialTypeList('sProvision')
  770. }
  771. },
  772. hendleEdit(val, index) {
  773. this.dialogVisible = false
  774. // let params = {
  775. // id: this.cid,
  776. // theTime: this.mainForm.date,
  777. // mainId: this.mainForm.type,
  778. // mainName: this.mainForm.mainName,
  779. // remark: this.mainForm.remark,
  780. // type: 2,
  781. // retailOrderItemList: this.goodsList,
  782. // policyId: this.policyId,
  783. // };
  784. // editData(params).then((res) => {
  785. // this.$successMsg("编辑成功");
  786. // this.getDetail();
  787. // });
  788. },
  789. // 获取条件相对应的比列
  790. handleFactor(e) {
  791. const data = this.factor.filter((k) => {
  792. return k.id == e
  793. })[0]
  794. // // consloe(data, "kkkk");
  795. this.pop = data.pop
  796. this.popArr = data.pop.split(':')
  797. this.screenForm.policyId = data.policyId
  798. this.policyConditionId = data.id
  799. },
  800. // 引用销售政策搜索
  801. async handlePolicyTypeList() {
  802. if (!this.screenForm.policyId) {
  803. this.$errorMsg('请选择销售政策')
  804. return
  805. }
  806. if (this.popArr.length) {
  807. this.popDataArr = []
  808. this.dataList = []
  809. for (let i = 0; i < this.popArr.length; i++) {
  810. await this.getConditionList(this.policyConditionId, i + 1, false)
  811. }
  812. } else {
  813. // sProvision = true
  814. this.getMaterialTypeList('sProvision')
  815. }
  816. },
  817. // 获取某一个比例下的数据 ,查询popType 当前 this.cusIndex+1
  818. async getConditionList(policyConditionId, popType, fang) {
  819. this.listLoading = true
  820. const { data } = await getConditionList({
  821. pageNum: this.currentPage,
  822. pageSize: -1,
  823. policyConditionId,
  824. popType,
  825. specification: this.screenForm.specification,
  826. saleTypeCode: this.screenForm.saleTypeCode,
  827. customerId: this.listItem ? this.listItem.customerId : '',
  828. })
  829. if (!fang) {
  830. this.poptotal['total' + popType] = data.total
  831. this.popcun['cun' + popType] = 1
  832. this.popfun['handleSizeChange' + popType] = (val, index) => {
  833. this.popcun['cun' + index] = val
  834. this.currentPage = 1
  835. this.getConditionList(this.policyConditionId, index, true)
  836. }
  837. this.popfun['handleCurrentChange' + popType] = (val, index) => {
  838. this.popcun['cun' + index] = val
  839. this.getConditionList(this.policyConditionId, index, true)
  840. }
  841. }
  842. const datas = data.records
  843. if (this.listItem) {
  844. for (let i = 0; i < this.goodsList.length; i++) {
  845. for (let j = 0; j < datas.length; j++) {
  846. if (datas[j].id == this.goodsList[i].policyMaterialId) {
  847. this.$set(datas[j], 'disabled', true)
  848. }
  849. }
  850. }
  851. }
  852. // this.total = data.total;
  853. // console.log(this.goodsList,'4555');
  854. if (this.goodsList.length) {
  855. for (let p = 0; p < this.goodsList.length; p++) {
  856. for (let q = 0; q < datas.length; q++) {
  857. if (this.goodsList[p].id == datas[q].id) {
  858. this.$set(datas[q], 'disabled', true)
  859. }
  860. }
  861. }
  862. }
  863. for (let i = 0; i < data.records.length; i++) {
  864. data.records[i].qty = 1
  865. data.records[i].policyMaterialId = data.records[i].id
  866. this.$set(
  867. data.records[i],
  868. 'zong',
  869. data.records[i].qty * data.records[i].price
  870. )
  871. data.records[i].sums1 = ['price', 'qty', 'zong']
  872. // this.$set(data.records[i],'userList',this.userList)
  873. }
  874. if (fang) {
  875. this.popDataArr[popType] = datas
  876. } else {
  877. this.popDataArr.push(datas)
  878. }
  879. this.totalArr.push({
  880. totalQty: 0,
  881. totalPrice: 0,
  882. totalAmount: 0
  883. })
  884. // this.$set(this.totalArr,[...this.totalArr])
  885. this.listLoading = false
  886. // consloe(this.popDataArr);
  887. },
  888. // 获取政策列表
  889. getMaterialTypeList(val) {
  890. this.listLoading2 = true
  891. getMaterialTypeList({
  892. pageNum: 1,
  893. pageSize: -1,
  894. policyId: this.screenForm.policyId,
  895. saleTypeCode: this.screenForm.saleTypeCode,
  896. specification: this.screenForm.specification,
  897. customerId: this.listItem ? this.listItem.customerId : '',
  898. [val]: true
  899. }).then((res) => {
  900. this.dataList = res.data.records
  901. if (this.listItem) {
  902. for (let i = 0; i < this.goodsList.length; i++) {
  903. for (let j = 0; j < this.dataList.length; j++) {
  904. if (this.dataList[j].id == this.goodsList[i].policyMaterialId) {
  905. this.$set(this.dataList[i], 'disabled', true)
  906. }
  907. }
  908. }
  909. }
  910. for (let i = 0; i < res.data.records.length; i++) {
  911. this.$set(
  912. res.data.records[i],
  913. 'qty',
  914. 1
  915. )
  916. res.data.records[i].sums1 = ['price', 'qty', 'zong']
  917. res.data.records[i].userList = this.userList
  918. res.data.records[i].policyMaterialId = res.data.records[i].id
  919. for (let j = 0; j < this.goodsList.length; j++) {
  920. if (this.goodsList[j].id == res.data.records[i].id) {
  921. res.data.records[i].disabled = false
  922. }
  923. }
  924. }
  925. this.dataList = res.data.records
  926. this.total = res.data.total
  927. this.listLoading2 = false
  928. this.popDataArr = []
  929. this.popArr = []
  930. // // consloe(this.dataList, "kkkk");
  931. })
  932. },
  933. // 下一步获取某个政策条件比例数据
  934. handleCondition() {
  935. if (this.multipleSelection.length) {
  936. this.cusIndex += 1
  937. this.disabled = true
  938. this.multipleData.push(this.multipleSelection)
  939. this.getConditionList(this.policyConditionId, this.cusIndex + 1)
  940. } else {
  941. this.$errorMsg('请选择')
  942. }
  943. // // consloe(this.cusIndex,'下');
  944. },
  945. // 上一步
  946. handleShang() {
  947. this.cusIndex == 0 ? (this.disabled = false) : ''
  948. this.multipleData.splice(this.cusIndex, 1)
  949. this.popDataArr.splice(this.cusIndex, 1)
  950. this.cusIndex -= 1
  951. // // consloe(this.cusIndex,'上');
  952. },
  953. /**
  954. * 根据条件禁用行复选框
  955. * 函数返回值为false则禁用选择(反之亦然)
  956. * @param {Object} row - 行数据
  957. * @param {String} index - 索引值
  958. * @return Boolean
  959. */
  960. selectable: function (row, index) {
  961. // row.disabled == undefined 才能被选中
  962. if (row.disabled == undefined) {
  963. return true
  964. }
  965. // 函数必须有返回值且是布尔值
  966. // 页面刷新后该函数会执行 N 次进行判断(N 为表格行数)
  967. // 如果没有返回值则默认返回false(全部无法选中)
  968. },
  969. /**
  970. * 根据条件禁用行复选框
  971. * 函数返回值为false则禁用选择(反之亦然)
  972. * @param {Object} row - 行数据
  973. * @param {String} index - 索引值
  974. * @return Boolean
  975. */
  976. selectable2: function (row, index) {
  977. // row.disabled == undefined 才能被选中
  978. if (row.disabled == undefined) {
  979. return true
  980. }
  981. // 函数必须有返回值且是布尔值
  982. // 页面刷新后该函数会执行 N 次进行判断(N 为表格行数)
  983. // 如果没有返回值则默认返回false(全部无法选中)
  984. },
  985. // 条件数据多选
  986. handleSelectionChange(val, type, index) {
  987. if (type === 1) {
  988. this.type = 1
  989. if (!this.multipleSelections.length) {
  990. this.multipleSelections = new Array(index).fill([])
  991. } else {
  992. for (let i = 0; i < this.multipleSelections.length; i++) {
  993. if (!this.multipleSelections[i] || !this.multipleSelections[i].length) {
  994. this.multipleSelections[i] = []
  995. }
  996. }
  997. }
  998. this.$set(this.multipleSelections, index, val)
  999. this.$set(this.totalArr, index, {
  1000. totalQty: 0,
  1001. totalPrice: 0,
  1002. totalAmount: 0
  1003. })
  1004. for (let j = 0; j < this.multipleSelections[index].length; j++) {
  1005. this.multipleSelections[index][j].fang = true
  1006. this.totalArr[index].totalQty +=
  1007. +this.multipleSelections[index][j].qty
  1008. this.totalArr[index].totalPrice +=
  1009. +this.multipleSelections[index][j].price
  1010. this.totalArr[index].totalAmount +=
  1011. +this.multipleSelections[index][j].price *
  1012. +this.multipleSelections[index][j].qty
  1013. }
  1014. // consloe(this.multipleSelections);
  1015. } else {
  1016. this.type = 2
  1017. this.multipleSelection = val
  1018. console.log(this.multipleSelection)
  1019. this.totalQty = this.totalPrice = this.totalAmount = 0
  1020. for (let i = 0; i < this.multipleSelection.length; i++) {
  1021. this.multipleSelection[i].fang = true
  1022. this.totalQty += +this.multipleSelection[i].qty
  1023. this.totalPrice += +this.multipleSelection[i].price
  1024. this.totalAmount +=
  1025. +this.multipleSelection[i].price *
  1026. +this.multipleSelection[i].qty
  1027. }
  1028. }
  1029. },
  1030. hanlePopData() {
  1031. console.log(this.multipleSelections)
  1032. this.multipleData.push(this.multipleSelection)
  1033. if (this.multipleData.length && this.multipleSelection.length) {
  1034. let arrData = []
  1035. for (let i = 0; i < this.multipleData.length; i++) {
  1036. if (this.multipleData[i].wallets && this.multipleData[i].wallets.length) {
  1037. this.multipleData[i].id = null
  1038. this.$set(this.multipleData[i], 'customerWalletId', this.multipleData[i].wallets[0].customerWalletId)
  1039. this.$set(this.multipleData[i], 'serviceName', this.multipleData[i].wallets[0].serviceName)
  1040. this.$set(this.multipleData[i], 'serviceId', this.multipleData[i].wallets[0].serviceId)
  1041. this.$set(this.multipleData[i], 'amount', 0)
  1042. }
  1043. arrData = [...arrData, ...this.multipleData[i]]
  1044. }
  1045. if (this.goodsList.length) {
  1046. this.goodsList = [...this.goodsList, ...arrData]
  1047. } else {
  1048. this.goodsList = arrData
  1049. }
  1050. if (this.dataList.length) {
  1051. for (let u = 0; u < this.goodsList.length; u++) {
  1052. this.goodsList[u].disabled = true
  1053. }
  1054. this.newDataList = this.multipleSelection
  1055. this.disabled = true
  1056. }
  1057. this.goodsList.forEach((item) => {
  1058. this.$set(item, 'status1', '')
  1059. this.$set(item, 'status2', '')
  1060. this.$set(item, 'userList', this.userList)
  1061. })
  1062. if (this.goodsList.length && this.goodsList[0].wallets.length) {
  1063. console.log(555555)
  1064. this.mainForm.k3ServiceName =
  1065. this.goodsList[0].wallets[0].serviceName || ''
  1066. this.mainForm.k3ServiceId =
  1067. this.goodsList[0].wallets[0].serviceId || ''
  1068. }
  1069. // if (this.goodsList.length>4) {
  1070. // this.newGoodsList = this.goodsList
  1071. // this.newGoodsList.length = 4
  1072. // }
  1073. this.cusIndex = 0
  1074. this.total = 0
  1075. this.popDataArr = []
  1076. this.multipleData = []
  1077. this.multipleSelection = []
  1078. this.policyId = this.screenForm.policyId
  1079. this.totalQty = this.totalPrice = this.totalAmount = 0
  1080. this.isShowDialog = false
  1081. this.$refs.singleTable.clearSelection()
  1082. // consloe(this.goodsList, "kkkk");
  1083. } else if (this.multipleSelections.length) {
  1084. let arrData = []
  1085. this.newMultipleSelections = this.multipleSelections
  1086. for (let i = 0; i < this.multipleSelections.length; i++) {
  1087. for (let j = 0; j < this.multipleSelections[i].length; j++) {
  1088. this.multipleSelections[i][j].disabled = true
  1089. this.multipleSelections[i][j].id = null
  1090. if (this.multipleSelections[i][j].wallets.length) {
  1091. this.$set(this.multipleSelections[i][j], 'customerWalletId', this.multipleSelections[i][j].wallets[0].customerWalletId)
  1092. this.$set(this.multipleSelections[i][j], 'serviceName', this.multipleSelections[i][j].wallets[0].serviceName)
  1093. this.$set(this.multipleSelections[i][j], 'serviceId', this.multipleSelections[i][j].wallets[0].serviceId)
  1094. this.$set(this.multipleSelections[i][j], 'amount', 0)
  1095. }
  1096. arrData = [...arrData, this.multipleSelections[i][j]]
  1097. }
  1098. }
  1099. if (this.goodsList.length) {
  1100. this.goodsList = [...this.goodsList, ...arrData]
  1101. } else {
  1102. this.goodsList = arrData
  1103. }
  1104. if (this.goodsList.length && this.goodsList[0].wallets.length) {
  1105. this.mainForm.k3ServiceName =
  1106. this.goodsList[0].wallets[0].serviceName || ''
  1107. this.mainForm.k3ServiceId =
  1108. this.goodsList[0].wallets[0].serviceId || ''
  1109. }
  1110. this.goodsList.forEach((item) => {
  1111. this.$set(item, 'status1', '')
  1112. this.$set(item, 'status2', '')
  1113. this.$set(item, 'userList', this.userList)
  1114. })
  1115. this.disabled = true
  1116. // this.popDataArr = [];
  1117. this.multipleData = []
  1118. this.multipleSelection = []
  1119. this.policyId = this.screenForm.policyId
  1120. this.totalQty = this.totalPrice = this.totalAmount = 0
  1121. this.isShowDialog = false
  1122. this.$refs.singleTable.forEach((k) => {
  1123. k.clearSelection()
  1124. })
  1125. // this.$refs.singleTable.clearSelection();
  1126. } else {
  1127. this.$errorMsg('请选择')
  1128. }
  1129. },
  1130. // 获取详情
  1131. getDetail() {
  1132. getUserList({
  1133. pageNum: 1,
  1134. pageSize: -1,
  1135. adminWebsitId: '',
  1136. isCustomer: 0,
  1137. roleId: '',
  1138. status: true,
  1139. userName: ''
  1140. }).then((res) => {
  1141. this.userList = res.data.records
  1142. getDetail({ id: this.listItem.id }).then(res => {
  1143. const data = res.data
  1144. this.mainForm.date = data.theTime
  1145. this.mainForm.type = data.mainId
  1146. this.mainForm.remark = data.remark
  1147. this.mainForm.policyId = data.policyId
  1148. this.policyId = data.policyId
  1149. this.mainForm.k3ServiceName = data.k3ServiceName
  1150. this.mainForm.k3ServiceId = data.k3ServiceId,
  1151. this.mainForm.fileNum = data.fileNum
  1152. // this.mainForm.k3ServiceName = data.retailOrderItemList[0].wallets[0].serviceName
  1153. // this.mainForm.k3ServiceId = data.retailOrderItemList[0].wallets[0].serviceId
  1154. data.retailOrderItemList.forEach((item) => {
  1155. item.status1 = ''
  1156. item.status2 = ''
  1157. this.$set(item, 'userList', this.userList)
  1158. item.rebateWallets.forEach(j => {
  1159. if (j.customerWalletId2 === data.customerWalletId2) {
  1160. this.$set(item, 'amount', j.amount || 0)
  1161. }
  1162. })
  1163. item.wallets.forEach((k) => {
  1164. if (k.customerWalletId === data.customerWalletId) {
  1165. this.$set(item, 'serviceId', k.serviceId)
  1166. this.$set(item, 'serviceName', k.serviceName)
  1167. }
  1168. })
  1169. })
  1170. this.goodsList = data.retailOrderItemList
  1171. })
  1172. })
  1173. },
  1174. // 获取销售政策
  1175. getPolicyList() {
  1176. policyList({
  1177. pageNum: 1,
  1178. pageSize: -1,
  1179. customerId: this.listItem ? this.listItem.customerId : '',
  1180. status: true
  1181. }).then((res) => {
  1182. if (this.policyId) {
  1183. this.screenForm.policyId = this.policyId
  1184. this.disabled = true
  1185. } else {
  1186. this.screenForm.policyId = res.data.records[0].code
  1187. }
  1188. this.policyList = res.data.records
  1189. if (this.policyList.length) {
  1190. this.handlePolicy(this.screenForm.policyId)
  1191. }
  1192. })
  1193. },
  1194. // 获取销售类型
  1195. getTypeList() {
  1196. const params = {
  1197. pageNum: 1,
  1198. pageSize: -1,
  1199. saleCode: '',
  1200. saleName: '',
  1201. status: ''
  1202. }
  1203. typeList(params).then((res) => {
  1204. this.ztypeList = res.data.records
  1205. // // consloe(this.ztypeList, "type1111");
  1206. })
  1207. },
  1208. // 获取仓库列表
  1209. getWarehouseList() {
  1210. getWarehouseList({
  1211. pageNum: 1,
  1212. pageSize: -1
  1213. }).then((res) => {
  1214. this.warehouseList = res.data.records
  1215. })
  1216. },
  1217. // 获取限定机型
  1218. getpolicyTypeList() {
  1219. getpolicyTypeList({
  1220. pageNum: 1,
  1221. pageSize: 10,
  1222. policyId: this.screenForm.policyId,
  1223. saleTypeCode: this.screenForm.saleTypeCode
  1224. }).then((res) => {
  1225. for (let i = 0; i < res.data.records.length; i++) {
  1226. this.$set(
  1227. res.data.records[i],
  1228. 'qty',
  1229. 1
  1230. )
  1231. res.data.records[i].sums2 = ['price', 'qty', 'zong']
  1232. res.data.records[i].userList = this.userList
  1233. }
  1234. this.dataList = res.data.records
  1235. this.total = res.data.total
  1236. })
  1237. },
  1238. // 打开引用
  1239. handleShow() {
  1240. this.isShowDialog = true
  1241. this.getPolicyList()
  1242. },
  1243. // 获取钱包列表
  1244. getWalletList() {
  1245. getWalletList({
  1246. customerId: JSON.parse(localStorage.getItem('supply_user')).customerId,
  1247. type: 'COMMONLY'
  1248. }).then((res) => {
  1249. this.xjWalletList = res.data
  1250. })
  1251. getWalletList({
  1252. customerId: JSON.parse(localStorage.getItem('supply_user')).customerId,
  1253. type: 'REBATE'
  1254. }).then((res) => {
  1255. this.flWalletList = res.data
  1256. })
  1257. },
  1258. // 获取销售类型列表
  1259. getSalesTypeList() {
  1260. getSalesTypeList({
  1261. pageNum: 1,
  1262. pageSize: -1
  1263. }).then((res) => {
  1264. this.salesTypeList = res.data.records
  1265. })
  1266. },
  1267. getDictList() {
  1268. getDictList({ sysDictEnum: 'PRODUCT_TYPE' }).then((res) => {
  1269. this.typeList = res.data
  1270. })
  1271. },
  1272. // 获取商品列表
  1273. getGoodsList() {
  1274. getGoodsList({
  1275. pageNum: this.currentPage,
  1276. pageSize: 10,
  1277. mainId: this.screenForm.type,
  1278. saleId: this.screenForm.salesType,
  1279. materialCode: this.screenForm.proNum,
  1280. materialName: this.screenForm.proName,
  1281. specification: this.screenForm.proModel,
  1282. price1: this.screenForm.price1,
  1283. price2: this.screenForm.price2
  1284. }).then((res) => {
  1285. const oldGoodsList = this.goodsList
  1286. const newGoodsList = res.data.records
  1287. for (let i = 0; i < oldGoodsList.length; i++) {
  1288. const oldItem = oldGoodsList[i]
  1289. for (let j = 0; j < newGoodsList.length; j++) {
  1290. const newItem = newGoodsList[j]
  1291. if (newItem.materialId === oldItem.materialId) {
  1292. newGoodsList[j].selected = true
  1293. break
  1294. }
  1295. }
  1296. }
  1297. res.data.records.forEach((item) => {
  1298. item.materialName = item.name
  1299. item.materialCode = item.number
  1300. item.saleTypeName = item.saleName
  1301. item.unit = item.baseUnit
  1302. item.price = item.batchPrice
  1303. item.tax = item.taxRate
  1304. item.isDirectTransfer = false
  1305. item.directTransferQty = ''
  1306. item.status1 = ''
  1307. item.status2 = ''
  1308. item.rebateAmount = ''
  1309. item.rebateRate = ''
  1310. item.productPriceId = item.id
  1311. })
  1312. this.leftGoodsList = res.data.records
  1313. this.listTotal = res.data.total
  1314. })
  1315. },
  1316. // 查询重复值并禁选
  1317. checkboxSelect(row, rowIndex) {
  1318. if (row.selected) {
  1319. return false // 禁用
  1320. } else {
  1321. return true // 不禁用
  1322. }
  1323. },
  1324. // 点击 选择商品
  1325. openDialog() {
  1326. this.getSalesTypeList()
  1327. this.getGoodsList()
  1328. this.isShowDialog = true
  1329. },
  1330. // 提交筛选表单
  1331. submitScreenForm() {
  1332. this.currentPage = 1
  1333. this.getGoodsList()
  1334. },
  1335. // 重置筛选表单
  1336. resetScreenForm() {
  1337. this.$refs.screenForm.resetFields()
  1338. this.currentPage = 1
  1339. this.getGoodsList()
  1340. },
  1341. // 关闭 弹窗
  1342. closeDialog() {
  1343. this.isShowDialog = false
  1344. this.popDataArr = []
  1345. },
  1346. // 删除
  1347. deleteGoods() {
  1348. const rightGoodsList = this.rightGoodsList
  1349. const rightSelection = this.rightSelection
  1350. for (let i = 0; i < rightGoodsList.length; i++) {
  1351. for (let j = 0; j < rightSelection.length; j++) {
  1352. if (rightSelection[j].materialId == rightGoodsList[i].materialId) {
  1353. this.rightGoodsList.splice(i, 1)
  1354. }
  1355. }
  1356. }
  1357. },
  1358. // 确定 添加产品
  1359. submitAddGoods() {
  1360. if (this.radio) {
  1361. const params = this.radio.split('&')
  1362. this.screenForm.policyId = params[1]
  1363. this.mainForm.policyId = params[1]
  1364. this.cusIndex += 1
  1365. getpolicyList({
  1366. materialId: params[2],
  1367. policyId: params[1]
  1368. }).then((res) => {
  1369. this.pop = res.data.pop
  1370. this.popArr = res.data.pop.split(':')
  1371. this.popArr.splice(0, 1)
  1372. for (let i = 0; i < this.popArr.length; i++) {
  1373. this.$set(this.radioObj, 'radio' + (i + 1), '')
  1374. }
  1375. this.step = this.cusIndex + 1
  1376. this.getConditionList(params[3], this.step)
  1377. })
  1378. } else {
  1379. this.$errorMsg('请选择')
  1380. }
  1381. },
  1382. // 更改每页数量
  1383. handleSizeChange(val) {
  1384. this.pageSize = val
  1385. this.currentPage = 1
  1386. this.getConditionList(this.policyConditionId, this.cusIndex + 1)
  1387. },
  1388. // 更改当前页
  1389. handleCurrentChange(val) {
  1390. this.currentPage = val
  1391. this.getConditionList(this.policyConditionId, this.cusIndex + 1)
  1392. },
  1393. // 更改列表当前页
  1394. handleTableCurrentChange(val) {
  1395. this.currentPage = val
  1396. this.getConditionList(this.policyConditionId, this.cusIndex + 1)
  1397. },
  1398. handleClose() {
  1399. this.totalQty = this.totalPrice = this.totalAmount = 0
  1400. // this.dataList = [];
  1401. // this.popDataArr = [];
  1402. // this.screenForm.policyId = "";
  1403. // this.screenForm.saleTypeCode = "";
  1404. },
  1405. // 删除产品
  1406. deleteItem(index, id) {
  1407. this.goodsList.splice(index, 1)
  1408. // this.dataList
  1409. this.newDataList.splice(index, 1)
  1410. if (!this.goodsList.length) {
  1411. this.disabled = false
  1412. this.policyId = ''
  1413. this.mainForm.policyId = ''
  1414. }
  1415. // this.popDataArr.splice(index,1)
  1416. },
  1417. // 修改返利钱包
  1418. changeWallet(e, row) {
  1419. if (e) {
  1420. const obj = row.rebateWallets.filter(k => {
  1421. return e === k.customerWalletId
  1422. })[0]
  1423. this.$set(row, 'rebateRate', (obj.rebateRate || 0))
  1424. this.$set(row, 'amount', obj.amount || 0)
  1425. } else {
  1426. this.$set(row, 'rebateRate', 0)
  1427. this.$set(row, 'amount', 0)
  1428. }
  1429. },
  1430. clearWallet(e) {
  1431. console.log(e)
  1432. // const obj = row.rebateWallets.filter(k => {
  1433. // return e === k.customerWalletId
  1434. // })[0]
  1435. this.$set(row, 'rebateRate', 0)
  1436. },
  1437. // 检查库存
  1438. checkStock() {
  1439. if (!this.warehouseValue) {
  1440. return this.$errorMsg('请选择仓库')
  1441. }
  1442. if (!this.goodsList) {
  1443. return this.$errorMsg('请添加货品')
  1444. }
  1445. const ids = []
  1446. this.goodsList.forEach((item) => {
  1447. ids.push(item.materialId)
  1448. })
  1449. checkStock({
  1450. correspondId: this.warehouseValue,
  1451. materialId: ids.join(',')
  1452. }).then((res) => {
  1453. if (res.data) {
  1454. this.goodsList.forEach((item, index) => {
  1455. item.status1 = res.data[index].allStockNum
  1456. item.status2 = res.data[index].stockNum
  1457. // // consloe(item.status1, item.status2);
  1458. })
  1459. }
  1460. })
  1461. },
  1462. status2Filter(item) {
  1463. if (
  1464. item.status2 === '' ||
  1465. item.status2 === null ||
  1466. item.status2 === undefined
  1467. ) return '未检查';
  1468. if (item.status2 <= 0) {
  1469. return '无货'
  1470. } else if (item.status2 >= 1 && item.status2 <= 30) {
  1471. return item.status2
  1472. } else if (item.status2 >= 31 && item.status2 <= 1000) {
  1473. return '有货'
  1474. } else {
  1475. return '充足'
  1476. }
  1477. // else if (item.status2 >= item.qty) return '可用'
  1478. // else return '短缺'
  1479. },
  1480. // 保存
  1481. clickSubmitForm() {
  1482. this.$refs.mainForm.validate((valid) => {
  1483. if (valid) {
  1484. // let mainName =
  1485. // this.typeList[
  1486. // findElem(this.typeList, "dictCode", this.mainForm.type)
  1487. // ].dictValue;
  1488. this.goodsList.userList = []
  1489. this.goodsList.forEach(k=>{
  1490. delete k.userList
  1491. })
  1492. const params = {
  1493. theTime: this.mainForm.date,
  1494. k3ServiceId: this.mainForm.k3ServiceId,
  1495. k3ServiceName: this.mainForm.k3ServiceName,
  1496. remark: this.mainForm.remark,
  1497. type: 2, // 1:普通零售单,2:政策零售单
  1498. retailOrderItemList: this.goodsList,
  1499. policyId: this.policyId,
  1500. fileNo: this.mainForm.fileNum
  1501. }
  1502. console.log(params)
  1503. if (this.listItem) {
  1504. console.log(params.listItem);
  1505. params.id = this.listItem.id
  1506. editData(params).then((res) => {
  1507. this.$successMsg('编辑成功')
  1508. this.goBack()
  1509. this.$parent.getList()
  1510. })
  1511. } else {
  1512. params.retailOrderItemList.forEach(k=>{
  1513. k.id = null
  1514. })
  1515. addData(params).then((res) => {
  1516. this.$successMsg('添加成功')
  1517. this.goBack()
  1518. this.$parent.getList()
  1519. })
  1520. }
  1521. }
  1522. })
  1523. }
  1524. }
  1525. }
  1526. </script>
  1527. <style scoped lang="scss">
  1528. .yinput {
  1529. ::v-deep .el-input__inner {
  1530. text-align: right;
  1531. }
  1532. }
  1533. .fr {
  1534. margin: 10px;
  1535. overflow: hidden;
  1536. }
  1537. .detail-container {
  1538. width: 100%;
  1539. height: 100%;
  1540. margin-bottom: 80px;
  1541. ::v-deep .el-table__append-wrapper {
  1542. overflow: initial;
  1543. }
  1544. }
  1545. .table {
  1546. margin-top: 20px 0 0 0;
  1547. background-color: rgb(237 237 237);
  1548. }
  1549. .page-footer .footer.hideSidebar {
  1550. margin-left: 0;
  1551. width: 100%;
  1552. }
  1553. .mybox {
  1554. padding: 20px 0;
  1555. text-align: right;
  1556. div:first-child {
  1557. flex: 0 0 55px;
  1558. }
  1559. div {
  1560. flex: 1 0 200px;
  1561. padding-right: 10px;
  1562. text-align: right;
  1563. }
  1564. }
  1565. .myselect{
  1566. ::v-deep .el-select-dropdown__item{
  1567. max-width: 500px;
  1568. }
  1569. }
  1570. .main-title {
  1571. display: flex;
  1572. justify-content: space-between;
  1573. align-items: center;
  1574. margin-top: 20px;
  1575. height: 60px;
  1576. border-bottom: 1px solid #dcdfe6;
  1577. margin-bottom: 20px;
  1578. .title {
  1579. font-size: 16px;
  1580. font-weight: 600;
  1581. padding-left: 10px;
  1582. }
  1583. }
  1584. .tables {
  1585. display: flex;
  1586. margin-top: 10px;
  1587. .table {
  1588. width: 45%;
  1589. }
  1590. .buttons {
  1591. display: flex;
  1592. flex-direction: column;
  1593. justify-content: center;
  1594. align-items: center;
  1595. padding: 0 10px;
  1596. button {
  1597. margin: 0;
  1598. margin-top: 10px;
  1599. }
  1600. }
  1601. }
  1602. .ellipsis {
  1603. overflow: hidden;
  1604. text-overflow: ellipsis;
  1605. white-space: nowrap;
  1606. }
  1607. </style>