retail_form.vue 68 KB

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