acquisitionManagementAdd.vue 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616
  1. <!-- <!--收购管理新增-->
  2. <template>
  3. <el-container class="container">
  4. <!-- <div class="type">{{type}}</div> -->
  5. <el-header class="header">
  6. <img class="head-icon" src="../../../public/img/icons/acquisition6.png" alt="">
  7. <div class="head-title">{{baseInfoForm.warehouseName}}</div>
  8. </el-header>
  9. <el-main v-show="isCountShow">
  10. <el-form ref="baseInfoForm" label-position="left" :model="baseInfoForm" label-width="120px">
  11. <el-row class="base-info">
  12. 基本信息
  13. </el-row>
  14. <div class="row1">
  15. <div class="grid-content">
  16. <el-form-item label="货名">
  17. <el-select v-model="selectVal" placeholder="请选择" @change="goodsChange" :disabled="!isEdit">
  18. <el-option v-for="item in goodnameList" :key="item.constValue" :label="item.constValue"
  19. :value="item.constValue">
  20. </el-option>
  21. </el-select>
  22. </el-form-item>
  23. </div>
  24. <div class="grid-content">
  25. <el-form-item label="基准水分(%)">
  26. <el-input type="number" @mousewheel.native.prevent v-model="baseInfoForm.waterBase" @input="changeBaseWater" :disabled="!isEdit"></el-input>
  27. </el-form-item>
  28. </div>
  29. <!-- <div v-if="baseInfoForm.paramType != '1'" class="grid-content"> -->
  30. <div class="grid-content">
  31. <el-form-item label="扣重比">
  32. <el-input type="number" @mousewheel.native.prevent v-model="baseInfoForm.deductWeight" :disabled="!isEdit"></el-input>
  33. </el-form-item>
  34. </div>
  35. <div class="grid-content">
  36. <el-form-item label="干粮收购价格(元/公斤)" label-width="180px">
  37. <el-input type="number" @mousewheel.native.prevent v-model="baseInfoForm.dryGrainPrice" :disabled="!isEdit"></el-input>
  38. </el-form-item>
  39. </div>
  40. </div>
  41. <div class="row2">
  42. <div class="grid-content">
  43. <el-form-item label="干粮水分(%)">
  44. <el-input type="number" @mousewheel.native.prevent v-model="baseInfoForm.waterMin" @input="changeMinWater" :disabled="!isEdit" id="aaa"></el-input>
  45. </el-form-item>
  46. </div>
  47. <div class="grid-content">
  48. <el-form-item label="水分上限(%)">
  49. <el-input type="number" @mousewheel.native.prevent v-model="baseInfoForm.waterMax" @input="changeMaxWater" :disabled="!isEdit"></el-input>
  50. </el-form-item>
  51. </div>
  52. <div class="grid-content">
  53. <el-form-item label="销售上限(吨/年)">
  54. <el-input type="number" @mousewheel.native.prevent v-model="baseInfoForm.saleLimit" :disabled="!isEdit"></el-input>
  55. </el-form-item>
  56. </div>
  57. <div class="grid-content">
  58. <el-form-item label="参数类型">
  59. <el-radio-group
  60. @change="paramTypeChange"
  61. v-model="baseInfoForm.paramType"
  62. :disabled="!isEdit"
  63. >
  64. <el-radio label="1" >升水扣重</el-radio>
  65. <el-radio label="2">升水扣钱</el-radio>
  66. </el-radio-group>
  67. </el-form-item>
  68. </div>
  69. </div>
  70. </el-form>
  71. <el-row class="row3">
  72. <div class="top">
  73. <div class="title">粮价设置</div>
  74. <el-button v-if="checkList.length<4" class="btn" @click="newSetPrice" :disabled="!isEdit">新增</el-button>
  75. </div>
  76. <div class="content" v-for="(item,index) in priceList" :key="index">
  77. <div class="top">
  78. <div class="left">
  79. <div v-if="baseInfoForm.paramType == '2'"class="text">基准单价(元/公斤)</div>
  80. <el-input v-if="baseInfoForm.paramType == '2'"type="number" @mousewheel.native.prevent v-model="item.basicUnitPrice" :disabled="!isEdit"></el-input>
  81. </div>
  82. <el-button @click="delSetPrice(item,index)" :disabled="!isEdit">删除</el-button>
  83. </div>
  84. <div class="level">
  85. <el-checkbox-group v-model="item.checkList" @change="changeLevel($event,index)">
  86. <el-checkbox label="一等" :disabled="!isEdit"></el-checkbox>
  87. <el-checkbox label="二等" :disabled="!isEdit"></el-checkbox>
  88. <el-checkbox label="三等" :disabled="!isEdit"></el-checkbox>
  89. <el-checkbox label="等外" :disabled="!isEdit"></el-checkbox>
  90. </el-checkbox-group>
  91. </div>
  92. <div class="count">
  93. <div class="left">
  94. <div>水分(%)</div>
  95. <div v-if="baseInfoForm.paramType == '2'">降幅(元/0.1%)</div>
  96. <div v-else>扣重比</div>
  97. </div>
  98. <div class="right">
  99. <div class="line"></div>
  100. <div class="jt-style"></div>
  101. <div v-for="(item1,index) in item.detailList">
  102. <div class="item-style">
  103. <div v-if="item1.type!=4" class="item-style-title">
  104. <span>{{item1.name}}{{item1.index}}</span>
  105. <el-button class="add" @click="add(item,item1,index)" v-if="item1.type!=3" :disabled="!isEdit">+
  106. </el-button>
  107. <el-button class="reduce" @click="reduce(item,item1,index)"
  108. v-show="item1.type!=1&&item1.type!=2&&item1.type!=3" :disabled="!isEdit">-</el-button>
  109. </div>
  110. <div v-show="item1.type!=4">
  111. <input v-if='item1.type==1' class="water-price" :class="item1.isWrite?'white-bgc':''" v-model="baseInfoForm.waterMin"
  112. :disabled="item1.isWrite?false:true"></input>
  113. <input v-if='item1.type==2' class="water-price" :class="item1.isWrite?'white-bgc':''" v-model="baseInfoForm.waterBase"
  114. :disabled="item1.isWrite?false:true"></input>
  115. <input v-if='item1.type==3' class="water-price" :class="item1.isWrite?'white-bgc':''" v-model="baseInfoForm.waterMax"
  116. :disabled="item1.isWrite?false:true"></input>
  117. <input v-if='item1.type==5' class="water-price" :class="item1.isWrite?'white-bgc':''" v-model="item1.water"
  118. :disabled="isEdit?false:true"></input>
  119. </div>
  120. <div class="circle" v-if="item1.type!=4"></div>
  121. </div>
  122. <div class="bottom-price">
  123. <input v-if="item1.type==4" class="water-price" :class="isEdit?'white-bgc':''" v-model="item1.jfprice" :disabled="!isEdit"></input>
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. </div>
  129. <el-button class="submit" @click="submit">{{submitName}}</el-button>
  130. </el-row>
  131. </el-main>
  132. <el-main v-show="!isCountShow">
  133. <div class="page2-content">
  134. <div class="titel">
  135. {{selectVal}}价格对照表(按水分)
  136. </div>
  137. <el-table :data="tableData" style="width: 100%" :row-class-name="tableRowClassName">
  138. <el-table-column prop="waterMin" label="水分下限(%)">
  139. </el-table-column>
  140. <el-table-column prop="waterMax" label="水分上限(%)">
  141. </el-table-column>
  142. <el-table-column prop="price1" label="一等单价">
  143. </el-table-column>
  144. <el-table-column prop="price2" label="二等单价">
  145. </el-table-column>
  146. <el-table-column prop="price3" label="三等单价">
  147. </el-table-column>
  148. <el-table-column prop="priceOther" label="等外单价">
  149. </el-table-column>
  150. </el-table>
  151. </div>
  152. <div class="bottom-btn">
  153. <div v-if="baseInfoForm.status=='审核中'" class="left">当前价格尚未通过审核,建议审核通过后进行打印</div>
  154. <div class="right">
  155. <el-button class="submit" @click="closeCount">关闭</el-button>
  156. <el-button class="submit" @click="print">打印</el-button>
  157. </div>
  158. </div>
  159. </el-main>
  160. </el-container>
  161. </template>
  162. <script>
  163. import {
  164. purchasePriceAdd,
  165. purchasePriceLook,
  166. purchasePriceEdit
  167. } from '@/model/houseSelfCollect/index'
  168. import {
  169. packList,
  170. } from '@/model/contarct/index'
  171. import {
  172. posthandle
  173. } from '@/model/purchasingManagement/index'
  174. export default {
  175. components: {
  176. },
  177. watch: {
  178. },
  179. data() {
  180. return {
  181. isShowTip:false,
  182. price: 0,
  183. left: [],
  184. right: [],
  185. selectVal: '',
  186. goodnameList: [],
  187. tableData: [],
  188. submitName: '提交',
  189. isCountShow: true,
  190. priceList: [{
  191. index: 0,
  192. checkList: [],
  193. basicUnitPrice: '',
  194. detailList: [{
  195. type: 1,
  196. name: '干粮',
  197. water: '',
  198. isWrite: false
  199. },
  200. {
  201. type: 4,
  202. jfprice: ''
  203. },
  204. {
  205. type: 2,
  206. name: '基准',
  207. water: '',
  208. isWrite: false
  209. },
  210. {
  211. type: 4,
  212. jfprice: ''
  213. },
  214. {
  215. type: 3,
  216. name: '上限',
  217. water: '',
  218. isWrite: false
  219. },
  220. ],
  221. }],
  222. splitPriceList: [],
  223. baseInfoForm: {
  224. warehouseId: '',
  225. warehouseName: '',
  226. compId: '',
  227. goodsNameKey: '',
  228. goodsName: '',
  229. waterBase: '',
  230. deductWeight: '',
  231. waterMin: '',
  232. waterMax: '',
  233. saleLimit: '',
  234. statusFlag: '',
  235. status: '',
  236. workflowId: '',
  237. approveStatus: '',
  238. passDate: '',
  239. dryGrainPrice: '',
  240. details: [],
  241. detailPrints: []
  242. },
  243. index: 0,
  244. type: '',
  245. isEdit: true,
  246. isSHowNewBtn: true,
  247. checkList: [],
  248. checkList1: [],
  249. checkList2: [],
  250. checkList3: [],
  251. checkList4: []
  252. }
  253. },
  254. activated() {
  255. // 货名
  256. let _goodsNameList = []
  257. _goodsNameList = this.$route.query.goodsNameList
  258. if (_goodsNameList == undefined) {
  259. _goodsNameList = []
  260. }
  261. packList({
  262. constId: 'CON2'
  263. })
  264. .toPromise()
  265. .then((response) => {
  266. let _list = []
  267. for (let i = 0; i < response.length; i++) {
  268. let _isAll = true
  269. for (let j = 0; j < _goodsNameList.length; j++) {
  270. if (response[i].constValue != _goodsNameList[j]) {
  271. if (j == _goodsNameList.length - 1 && _isAll) {
  272. _list.push(response[i])
  273. }
  274. } else {
  275. _isAll = false
  276. }
  277. }
  278. }
  279. if (_goodsNameList.length == 0) {
  280. this.goodnameList = response
  281. this.selectVal = response[0].constValue
  282. } else {
  283. this.goodnameList = _list
  284. if (_list.length != 0) {
  285. this.selectVal = _list[0].constValue
  286. }
  287. }
  288. })
  289. this.isCountShow = true
  290. switch (this.$route.query.type) {
  291. case '新增':
  292. this.submitName = '提交'
  293. this.isCountShow = true
  294. this.checkList=[]
  295. this.baseInfoForm = {
  296. warehouseId: '',
  297. warehouseName: '',
  298. compId: '',
  299. goodsNameKey: '',
  300. goodsName: '',
  301. waterBase: '',
  302. deductWeight: '',
  303. waterMin: '',
  304. waterMax: '',
  305. saleLimit: 2000,
  306. statusFlag: '',
  307. status: '',
  308. workflowId: '',
  309. approveStatus: '',
  310. passDate: '',
  311. dryGrainPrice: '',
  312. details: [],
  313. detailPrints: [],
  314. paramType:'1'
  315. }
  316. this.baseInfoForm.warehouseId = this.$route.query.warehouseId
  317. this.baseInfoForm.warehouseName = this.$route.query.warehouseName
  318. this.baseInfoForm.compId = this.$route.query.compId
  319. this.type = this.$route.query.type
  320. this.priceList[0].detailList[0].water = this.baseInfoForm.waterMin
  321. this.priceList[0].detailList[2].water = this.baseInfoForm.waterBase
  322. this.priceList[0].detailList[4].water = this.baseInfoForm.waterMax
  323. this.isEdit = true
  324. this.priceList = [{
  325. index: 0,
  326. checkList: [],
  327. basicUnitPrice: '',
  328. detailList: [{
  329. type: 1,
  330. name: '干粮',
  331. water: '',
  332. isWrite: false
  333. },
  334. {
  335. type: 4,
  336. jfprice: ''
  337. },
  338. {
  339. type: 2,
  340. name: '基准',
  341. water: '',
  342. isWrite: false
  343. },
  344. {
  345. type: 4,
  346. jfprice: ''
  347. },
  348. {
  349. type: 3,
  350. name: '上限',
  351. water: '',
  352. isWrite: false
  353. },
  354. ],
  355. }]
  356. break;
  357. case '编辑':
  358. this.isEdit = true;
  359. this.submitName = '提交'
  360. this.getData()
  361. break;
  362. case '审核中':
  363. this.isEdit = true;
  364. this.submitName = '通过'
  365. this.getData()
  366. break;
  367. case '查看':
  368. this.isEdit = false;
  369. this.submitName = '计算'
  370. this.getData()
  371. break;
  372. default:
  373. break
  374. }
  375. },
  376. mounted() {},
  377. methods: {
  378. paramTypeChange(e){
  379. // this.makeTableList()
  380. },
  381. // 查看/编辑获取数据
  382. getData() {
  383. this.type = this.$route.query.type
  384. this.baseInfoForm = JSON.parse(this.$route.query.data)
  385. purchasePriceLook({
  386. id: this.baseInfoForm.id
  387. }).toPromise().then((response) => {
  388. this.baseInfoForm = response
  389. //构造查看priceList数据
  390. this.priceList = []
  391. this.makeLookPriceList()
  392. if(this.$route.query.type != '新增'){
  393. let _data = this.priceList
  394. this.checkList1 = []
  395. this.checkList2 = []
  396. this.checkList3 = []
  397. this.checkList4 = []
  398. for (let i = 0; i < _data.length; i++) {
  399. if (i == 0) this.checkList1 = _data[i].checkList
  400. if (i == 1) this.checkList2 = _data[i].checkList
  401. if (i == 2) this.checkList3 = _data[i].checkList
  402. if (i == 3) this.checkList4 = _data[i].checkList
  403. }
  404. this.checkList = [...new Set([...this.checkList1, ...this.checkList2, ...this.checkList3, ...this.checkList4])]
  405. }
  406. })
  407. },
  408. goodsChange(e) {
  409. },
  410. changeBaseWater(val) {
  411. for (let i = 0; i < this.priceList.length; i++) {
  412. for (let k = 0; k < this.priceList[i].detailList.length; k++) {
  413. if (this.priceList[i].detailList[k].type == 2) {
  414. this.priceList[i].detailList[k].water = val
  415. }
  416. }
  417. }
  418. },
  419. changeMinWater(val) {
  420. for (let i = 0; i < this.priceList.length; i++) {
  421. for (let k = 0; k < this.priceList[i].detailList.length; k++) {
  422. if (this.priceList[i].detailList[k].type == 1) {
  423. this.priceList[i].detailList[k].water = val
  424. }
  425. }
  426. }
  427. },
  428. changeMaxWater(val) {
  429. for (let i = 0; i < this.priceList.length; i++) {
  430. for (let k = 0; k < this.priceList[i].detailList.length; k++) {
  431. if (this.priceList[i].detailList[k].type == 3) {
  432. this.priceList[i].detailList[k].water = val
  433. }
  434. }
  435. }
  436. },
  437. // 设置表格颜色
  438. tableRowClassName({
  439. row,
  440. rowIndex
  441. }) {
  442. if ((rowIndex + 1) % 2 === 0) {
  443. return 'double';
  444. } else {
  445. return 'single';
  446. }
  447. },
  448. getRowClass({
  449. rowIndex
  450. }) {
  451. if (rowIndex == 0) {
  452. return 'background:#ebeaef'
  453. } else {
  454. return ''
  455. }
  456. // return '';
  457. },
  458. // 增加分界
  459. add(item, item1, index) {
  460. // let _data = this.detailList;
  461. if (item.index > 2) {
  462. this.$message({
  463. message: '最多插入3个分界值',
  464. type: 'warning'
  465. });
  466. } else {
  467. item.index++
  468. item.detailList.splice(index + 1, 0, {
  469. name: '分界',
  470. water: '',
  471. type: 5,
  472. index: 1,
  473. isWrite: true
  474. });
  475. item.detailList.splice(index + 1, 0, {
  476. jfprice: '',
  477. type: 4
  478. });
  479. this.makeSpliceIndex(item, item1, index)
  480. }
  481. },
  482. // 减少分界
  483. reduce(item, item1, index) {
  484. item.index--
  485. item.detailList.splice(index, 2);
  486. },
  487. // 设置分界索引排序
  488. makeSpliceIndex(item, item1) {
  489. let _index = 0
  490. for (let j = 0; j < item.detailList.length; j++) {
  491. if (item.detailList[j].type == 5) {
  492. _index++
  493. item.detailList[j].index = _index;
  494. }
  495. }
  496. },
  497. // 复选框变化监听
  498. changeLevel(val, index) {
  499. let _data = this.priceList
  500. this.checkList1 = []
  501. this.checkList2 = []
  502. this.checkList3 = []
  503. this.checkList4 = []
  504. for (let i = 0; i < _data.length; i++) {
  505. let _childData = _data[i].checkList
  506. for (let k = 0; k < _childData.length; k++) {
  507. for (let j = 0; j < val.length; j++) {
  508. if (val[j] == _childData[k] && i != index) {
  509. _childData.splice(k, 1)
  510. }
  511. }
  512. }
  513. if (i == 0) this.checkList1 = _data[i].checkList
  514. if (i == 1) this.checkList2 = _data[i].checkList
  515. if (i == 2) this.checkList3 = _data[i].checkList
  516. if (i == 3) this.checkList4 = _data[i].checkList
  517. }
  518. this.checkList = [...new Set([...this.checkList1, ...this.checkList2, ...this.checkList3, ...this.checkList4])]
  519. },
  520. // 算价格纠正精度不准
  521. accMul(arg1, arg2) {
  522. var m = 0,
  523. s1 = arg1.toString(),
  524. s2 = arg2.toString();
  525. try {
  526. m += s1.split('.')[1].length
  527. } catch (e) {}
  528. try {
  529. m += s2.split('.')[1].length
  530. } catch (e) {}
  531. return Number(s1.replace('.', '')) * Number(s2.replace('.', '')) / Math.pow(10, m)
  532. },
  533. //保留两位小数
  534. keepTwoDecimal(num) {
  535. var result = parseFloat(num);
  536. if (isNaN(result)) {
  537. return false;
  538. }
  539. result = Math.round(result * 10000) / 10000;
  540. return result;
  541. },
  542. //保留两位小数
  543. keepOneDecimal(num) {
  544. var result = parseFloat(num);
  545. if (isNaN(result)) {
  546. return false;
  547. }
  548. result = Math.round(result * 100) / 100;
  549. return result;
  550. },
  551. // 添加粮价设置
  552. newSetPrice() {
  553. let _newObj = {
  554. index: 0,
  555. checkList: [],
  556. detailList: [{
  557. type: 1,
  558. name: '干粮',
  559. water: this.baseInfoForm.waterMin,
  560. isWrite: false
  561. },
  562. {
  563. type: 4,
  564. jfprice: ''
  565. },
  566. {
  567. type: 2,
  568. name: '基准',
  569. water: this.baseInfoForm.waterBase,
  570. isWrite: false
  571. },
  572. {
  573. type: 4,
  574. jfprice: ''
  575. },
  576. {
  577. type: 3,
  578. name: '上限',
  579. water: this.baseInfoForm.waterMax,
  580. isWrite: false
  581. },
  582. ],
  583. }
  584. this.priceList.push(_newObj)
  585. },
  586. // 删除价格组
  587. delSetPrice(item, index) {
  588. let that = this
  589. this.checkList1 = []
  590. this.checkList2 = []
  591. this.checkList3 = []
  592. this.checkList4 = []
  593. for (let i = 0; i < item.checkList.length; i++) {
  594. for (let j = 0; j < this.checkList.length; j++) {
  595. if (item.checkList[i] == this.checkList[j]) {
  596. this.checkList.splice(j, 1)
  597. }
  598. }
  599. }
  600. this.$confirm(
  601. '确认删除本组设置?',
  602. '提示', {
  603. confirmButtonText: '确定',
  604. cancelButtonText: '取消',
  605. type: 'warning',
  606. }
  607. )
  608. .then(() => {
  609. if (that.priceList.length == 1) {
  610. that.$message({
  611. message: '至少保留一组粮价设置',
  612. type: 'warning'
  613. });
  614. } else {
  615. that.priceList.splice(index, 1)
  616. that.baseInfoForm.details.split(index, 1)
  617. }
  618. })
  619. .catch(() => {
  620. return false
  621. })
  622. },
  623. //构造新增价格数据
  624. makePriceDataList() {
  625. for (let k = 0; k < this.priceList.length; k++) {
  626. // 新增
  627. let _detailsObj = {
  628. compId: this.baseInfoForm.warehouseId,
  629. basePrice: this.priceList[k].basicUnitPrice,
  630. level: '',
  631. point: '',
  632. pointPrice: ''
  633. }
  634. for (let j = 0; j < this.priceList[k].checkList.length; j++) {
  635. if (j == 0) {
  636. _detailsObj.level += this.priceList[k].checkList[j]
  637. } else {
  638. _detailsObj.level += ',' + this.priceList[k].checkList[j]
  639. }
  640. }
  641. let _index = 0
  642. let _index1 = 0
  643. for (let i = 0; i < this.priceList[k].detailList.length; i++) {
  644. if (this.priceList[k].detailList[i].type == 4) {
  645. if (_index == 0) {
  646. _index++
  647. _detailsObj.pointPrice += this.priceList[k].detailList[i].jfprice
  648. } else {
  649. _detailsObj.pointPrice += ',' + this.priceList[k].detailList[i].jfprice
  650. }
  651. } else if (_index1 == 0) {
  652. _index1++
  653. _detailsObj.point += this.priceList[k].detailList[i].water
  654. } else {
  655. _detailsObj.point += ',' + this.priceList[k].detailList[i].water
  656. }
  657. }
  658. this.baseInfoForm.details.push(_detailsObj)
  659. }
  660. },
  661. //打印
  662. print() {
  663. localStorage.setItem('pricePrintList', JSON.stringify(this.baseInfoForm.detailPrints));
  664. window.open('../../../static/print.html?name=' + this.baseInfoForm.goodsName)
  665. },
  666. validate() {
  667. let that = this
  668. function _baseWaterValidate(min, max, saveNum, point, type, inputVal) {
  669. let _val1 = inputVal
  670. let _pointVal1 = _val1.toString().split('.')[1]
  671. if (_pointVal1 == undefined) _pointVal1 = 0
  672. if (typeof(_pointVal1) == 'string') _pointVal1 = _pointVal1.length
  673. let _tobeVal1 = _val1 % point
  674. if (type == 'waterBase') {
  675. if (_val1 <= max && _val1 >= min && _pointVal1 <= saveNum ) {
  676. return false
  677. }
  678. }
  679. if (type == 'deductWeight') {
  680. if (_val1 <= max && _val1 >= min && _pointVal1 <= saveNum) {
  681. return false
  682. }
  683. }
  684. if (type == 'saleLimit') {
  685. if (_val1 <= max && _val1 >= min) {
  686. // Number.isInteger(that.baseInfoForm.saleLimit)
  687. return false
  688. }
  689. }
  690. return true
  691. }
  692. if (this.baseInfoForm.waterBase == '' || _baseWaterValidate(1, 100, 1, 0.1, 'waterBase', parseFloat(this
  693. .baseInfoForm.waterBase))) {
  694. if (_baseWaterValidate(1, 100, 1, 0.1, 'waterBase', parseFloat(this.baseInfoForm.waterBase))) {
  695. that.$message.error('水分基准输入错误,最多保留1位小数,基准水分须可被0.1整除!');
  696. } else {
  697. this.$message.error('基准水分不能为空!');
  698. }
  699. return false
  700. }
  701. if(this.baseInfoForm.paramType == '2'){
  702. if (this.baseInfoForm.deductWeight == '' || _baseWaterValidate(0, 3, 2, '', 'deductWeight', parseFloat(this
  703. .baseInfoForm.deductWeight))) {
  704. if (_baseWaterValidate(0, 3, 2, '', 'deductWeight', parseFloat(this.baseInfoForm.deductWeight))) {
  705. that.$message.error('扣重比输入错误!');
  706. } else {
  707. this.$message.error('扣重比不能为空!');
  708. }
  709. return false
  710. }
  711. }
  712. if (this.baseInfoForm.dryGrainPrice == '' || _baseWaterValidate(0, 1000, 4, '', 'deductWeight', parseFloat(this
  713. .baseInfoForm.dryGrainPrice))) {
  714. if (_baseWaterValidate(0, 1000, 4, '', 'deductWeight', parseFloat(this.baseInfoForm.dryGrainPrice))) {
  715. that.$message.error('干粮收购价输入错误!');
  716. } else {
  717. this.$message.error('干粮收购价格不能为空!');
  718. }
  719. return false
  720. }
  721. if (this.baseInfoForm.waterMin == '' || _baseWaterValidate(1, 100, 1, 0.1, 'waterBase', parseFloat(this
  722. .baseInfoForm.waterMin))) {
  723. if (this.baseInfoForm.waterMin == '') {
  724. this.$message.error('干粮水分不能为空!')
  725. }
  726. if (_baseWaterValidate(1, 100, 1, 0.1, 'waterBase', parseFloat(this.baseInfoForm.waterMin))) {
  727. that.$message.error('干粮水分输入错误,最多保留1位小数,干粮水分须可被0.1整除!')
  728. }
  729. return false
  730. }
  731. if (Number(this.baseInfoForm.waterBase)>Number(this.baseInfoForm.waterMax)) {
  732. this.$message.error('基准水分须小于水分上限!')
  733. return false
  734. }
  735. if (Number(this.baseInfoForm.waterMin)>Number(this.baseInfoForm.waterBase)) {
  736. this.$message.error('干粮水分须小于基准水分!')
  737. return false
  738. }
  739. if (this.baseInfoForm.waterMax == '' || _baseWaterValidate(1, 100, 1, 0.1, 'waterBase', parseFloat(this
  740. .baseInfoForm.waterMax))) {
  741. if (_baseWaterValidate(1, 100, 1, 0.1, 'waterBase', parseFloat(this.baseInfoForm.waterMax))) {
  742. that.$message.error('水分上限输入错误,最多保留1位小数,干粮水分须可被0.1整除!');
  743. } else {
  744. this.$message.error('水分上限不能为空!');
  745. }
  746. return false
  747. }
  748. if (this.baseInfoForm.saleLimit == '' || _baseWaterValidate(100, 100000, '', '', 'saleLimit', parseFloat(this
  749. .baseInfoForm.saleLimit))) {
  750. if (_baseWaterValidate(100, 100000, '', '', 'saleLimit', parseFloat(this.baseInfoForm.saleLimit))) {
  751. that.$message.error('销售上限输入错误!');
  752. } else {
  753. that.$message.error('销售上限不能为空!');
  754. }
  755. return false
  756. }
  757. if (this.checkList.length != 4) {
  758. this.$message.error('粮价设置为4个等级!');
  759. return false
  760. }
  761. for (let i = 0; i < this.priceList.length; i++) {
  762. let _item = this.priceList[i]
  763. if (this.baseInfoForm.paramType == '2' &&(_item.basicUnitPrice == '' || _baseWaterValidate(0, 50, 8, '', 'deductWeight', parseFloat(_item
  764. .basicUnitPrice)))) {
  765. if (_item.basicUnitPrice == '') {
  766. that.$message.error('基准单价不能为空!');
  767. } else {
  768. that.$message.error('基准单价输入错误,0-50数字最多保留两位小数!');
  769. }
  770. return false
  771. }
  772. if (_item.checkList.length == 0) {
  773. this.$message.error('等级不能为空!');
  774. return false
  775. }
  776. var arr = []
  777. for (let j = 0; j < _item.detailList.length; j++) {
  778. let _item1 = _item.detailList[j]
  779. if (_item1.type == 4) {
  780. if (_item1.jfprice == '' || _baseWaterValidate(0, 100, 8, '', 'deductWeight', parseFloat(_item1
  781. .jfprice))) {
  782. if (_item1.jfprice == '') {
  783. if(this.baseInfoForm.paramType == '1'){
  784. that.$message.error('扣重比不能为空!');
  785. }
  786. else{
  787. that.$message.error('降幅价格不能为空!');
  788. }
  789. } else {
  790. if(this.baseInfoForm.paramType == '1'){
  791. that.$message.error('扣重比输入错误!');
  792. }
  793. else{
  794. that.$message.error('降幅输入错误!');
  795. }
  796. }
  797. return false
  798. }
  799. } else {
  800. if (_item1.water == '' || _baseWaterValidate(0, 100, 1, 0.1, 'waterBase', parseFloat(_item1.water))) {
  801. if (_item1.water == '') {
  802. that.$message.error('分界水分不能为空!')
  803. } else {
  804. that.$message.error('分界值输入错误!');
  805. }
  806. return false
  807. }
  808. arr.push(_item1.water)
  809. }
  810. }
  811. if(!this.isIncrease(arr,arr.length)){
  812. that.$message.error('水分大小排序错误!');
  813. return false
  814. }
  815. }
  816. return true
  817. },
  818. getEditCheckList() {
  819. let _data = this.baseInfoForm.details
  820. let _list = []
  821. for (let k = 0; k < _data.length; k++) {
  822. let _list1 = []
  823. _list1 = _data[k].level.split(',')
  824. _list = _list.concat(_list1)
  825. }
  826. this.checkList = [...new Set(_list)];
  827. console.log(this.checkList)
  828. },
  829. isIncrease(arr,len){
  830. if(len == 1){
  831. return true
  832. }
  833. return (arr[len - 2] <= arr[len - 1]) && this.isIncrease(arr,len - 1)
  834. },
  835. // 提交
  836. submit() {
  837. let isValidate = false
  838. isValidate = this.validate()
  839. if (isValidate) {
  840. debugger
  841. this.makeTableList()
  842. this.baseInfoForm.details = []
  843. this.makePriceDataList()
  844. this.baseInfoForm.goodsName = this.selectVal
  845. switch (this.$route.query.type) {
  846. case '查看':
  847. this.isCountShow = false;
  848. break;
  849. case '新增':
  850. isValidate = this.validate()
  851. if (isValidate) {
  852. purchasePriceAdd(this.baseInfoForm).toPromise().then((response) => {
  853. // this.tableData = response.records
  854. this.isCountShow = false
  855. })
  856. }
  857. break;
  858. case '编辑':
  859. this.getEditCheckList()
  860. isValidate = this.validate()
  861. if (isValidate) {
  862. purchasePriceEdit(this.baseInfoForm).toPromise().then((response) => {
  863. this.isCountShow = false
  864. })
  865. }
  866. break;
  867. case '审核中':
  868. // this.makePriceDataList()
  869. this.getEditCheckList()
  870. isValidate = this.validate()
  871. if (isValidate) {
  872. let that = this
  873. this.$confirm(`是否确定通过?`, {
  874. cancelButtonText: '取消',
  875. confirmButtonText: '确定',
  876. type: 'warning',
  877. }).then(() => {
  878. purchasePriceEdit(this.baseInfoForm).toPromise().then((response) => {
  879. //审核
  880. that.audit(this.baseInfoForm, true, 2)
  881. })
  882. })
  883. }
  884. break;
  885. }
  886. }
  887. },
  888. //审核
  889. audit(item, status, status2) {
  890. posthandle({
  891. taskId: item.taskId,
  892. approved: status,
  893. auditMind: '',
  894. needReapply: status2 != undefined ? true : false,
  895. })
  896. .toPromise()
  897. .then((response) => {
  898. this.isCountShow = false
  899. this.isShowTip = true
  900. this.getData()
  901. })
  902. .catch((req) => {
  903. this.$message.warning(req.message)
  904. })
  905. },
  906. // 关闭
  907. closeCount() {
  908. this.isCountShow = true
  909. this.splitPriceList = []
  910. this.$router.push({
  911. name: 'acquisitionManagement',
  912. })
  913. },
  914. //处理价格表格数据
  915. makeTableList() {
  916. // 获取等级对应分界钱数
  917. this.getSplitPrice()
  918. // 构造表格等差数列
  919. let _list = []
  920. let _obj = {}
  921. let _waterMin = parseFloat(this.baseInfoForm.waterMin)
  922. let _waterMax = parseFloat(this.baseInfoForm.waterBase)
  923. let _count = Number(((_waterMax - _waterMin) / 0.1).toFixed(0))
  924. if(this.baseInfoForm.paramType == '2'){
  925. for (let i = 0; i < _count; i++) {
  926. // if (i == 0) {
  927. // _waterMax -= 0.1
  928. // }
  929. // else {
  930. // _waterMax -= 0.5
  931. // }
  932. _waterMax -= 0.1
  933. let priceList = this.calculatePrice(this.keepOneDecimal(_waterMax ))
  934. _obj = {
  935. waterMin: this.keepOneDecimal(_waterMax ),
  936. waterMax: this.keepOneDecimal(_waterMax + 0.09),
  937. price1: this.keepTwoDecimal(priceList[0]),
  938. price2: this.keepTwoDecimal(priceList[1]),
  939. price3: this.keepTwoDecimal(priceList[2]),
  940. priceOther: this.keepTwoDecimal(priceList[3]),
  941. }
  942. _list.unshift(_obj)
  943. }
  944. _obj = {}
  945. _waterMin = parseFloat(this.baseInfoForm.waterBase)
  946. _waterMax = parseFloat(this.baseInfoForm.waterMax)
  947. _count = Number(((_waterMax - _waterMin) / 0.1).toFixed(0))
  948. for (let i = 0; i < _count; i++) {
  949. // if (i == 0) {
  950. // _waterMin += 0.4
  951. // } else {
  952. // _waterMin += 0.5
  953. // }
  954. if (i != 0) {
  955. _waterMin += 0.1
  956. }
  957. let priceList = this.calculatePriceRight(this.keepOneDecimal(_waterMin ))
  958. _obj = {
  959. waterMin: this.keepOneDecimal(_waterMin ),
  960. waterMax: this.keepOneDecimal(_waterMin + 0.09),
  961. price1: this.keepTwoDecimal(priceList[0]),
  962. price2: this.keepTwoDecimal(priceList[1]),
  963. price3: this.keepTwoDecimal(priceList[2]),
  964. priceOther: this.keepTwoDecimal(priceList[3]),
  965. }
  966. _list.push(_obj)
  967. console.log('_list', _list)
  968. }
  969. }
  970. else{
  971. _obj = {}
  972. _waterMin = parseFloat(this.baseInfoForm.waterMin)
  973. _waterMax = parseFloat(this.baseInfoForm.waterMax)
  974. _count = (_waterMax - _waterMin) / 0.1
  975. for (let i = 0; i < _count; i++) {
  976. // if (i == 0) {
  977. // _waterMin += 0.4
  978. // } else {
  979. // _waterMin += 0.5
  980. // }
  981. if (i != 0) {
  982. _waterMin += 0.1
  983. }
  984. let priceList = this.calculatePriceRight(this.keepOneDecimal(_waterMin ))
  985. _obj = {
  986. waterMin: this.keepOneDecimal(_waterMin ),
  987. waterMax: this.keepOneDecimal(_waterMin + 0.09),
  988. price1: this.keepTwoDecimal(priceList[0]),
  989. price2: this.keepTwoDecimal(priceList[1]),
  990. price3: this.keepTwoDecimal(priceList[2]),
  991. priceOther: this.keepTwoDecimal(priceList[3]),
  992. }
  993. _list.push(_obj)
  994. console.log('_list', _list)
  995. }
  996. }
  997. this.baseInfoForm.detailPrints = _list
  998. this.tableData = _list
  999. },
  1000. // 获取分界价格数据,构造分界价格区间数据
  1001. getSplitPrice() {
  1002. let that = this;
  1003. this.left = []
  1004. this.right = []
  1005. let _priceList = this.priceList;
  1006. for (let i = 0; i < _priceList.length; i++) {
  1007. for (let k = 0; k < _priceList[i].checkList.length; k++) {
  1008. let _leftObj = {}
  1009. _leftObj.level = _priceList[i].checkList[k]
  1010. _leftObj.basicUnitPrice = parseFloat(_priceList[i].basicUnitPrice)
  1011. _leftObj.priceList = []
  1012. _leftObj.haveSplit = false
  1013. let _rightObj = {}
  1014. _rightObj.level = _priceList[i].checkList[k]
  1015. _rightObj.basicUnitPrice = parseFloat(_priceList[i].basicUnitPrice)
  1016. _rightObj.priceList = []
  1017. _rightObj.haveSplit = false
  1018. //获取基准在x轴索引
  1019. let index = 0
  1020. for(;index<_priceList[i].detailList.length;index++){
  1021. if(_priceList[i].detailList[index].water==that.baseInfoForm.waterBase){
  1022. break
  1023. }
  1024. }
  1025. console.log(index)
  1026. for (let j = index; j >= 0; j--) {
  1027. if (_priceList[i].detailList[j] && _priceList[i].detailList[j].type != 4) {
  1028. if (_priceList[i].detailList[j].type != 1) {
  1029. let baseprice = ''
  1030. if(this.baseInfoForm.paramType == '1'){
  1031. if (j == index) {
  1032. baseprice = parseFloat(_priceList[i].basicUnitPrice)
  1033. } else {
  1034. baseprice = parseFloat(parseFloat(_priceList[i].basicUnitPrice) + (parseFloat(_priceList[i].detailList[j + 2]
  1035. .water) - parseFloat(_priceList[i].detailList[j].water)) / 0.1 * (this.baseInfoForm.dryGrainPrice * (parseFloat(_priceList[i].detailList[j].water)
  1036. - parseFloat(_priceList[i].detailList[j - 2].water))*parseFloat(_priceList[i].detailList[j - 1].jfprice)/100/((parseFloat(_priceList[i].detailList[j].water)
  1037. - parseFloat(_priceList[i].detailList[j - 2].water))/0.1)))
  1038. }
  1039. _leftObj.priceList.push({
  1040. index: j,
  1041. priceStart: parseFloat(_priceList[i].detailList[j].water),
  1042. priceEnd: parseFloat(_priceList[i].detailList[j - 2].water),
  1043. type: parseFloat(_priceList[i].detailList[j].type),
  1044. water: _priceList[i].detailList[j].water,
  1045. jfprice: parseFloat(this.baseInfoForm.dryGrainPrice * (parseFloat(_priceList[i].detailList[j].water)
  1046. - parseFloat(_priceList[i].detailList[j - 2].water))*parseFloat(_priceList[i].detailList[j - 1].jfprice)/100/((parseFloat(_priceList[i].detailList[j].water)
  1047. - parseFloat(_priceList[i].detailList[j - 2].water))/0.1)),
  1048. baseprice: baseprice,
  1049. price: (parseFloat(_priceList[i].detailList[j].water) - parseFloat(_priceList[i].detailList[j -
  1050. 2].water)) / 0.1 * parseFloat(_priceList[i].detailList[j - 1].jfprice)
  1051. })
  1052. }
  1053. else{
  1054. if (j == index) {
  1055. baseprice = parseFloat(_priceList[i].basicUnitPrice)
  1056. } else {
  1057. baseprice = parseFloat(parseFloat(_priceList[i].basicUnitPrice) + (parseFloat(_priceList[i].detailList[j + 2]
  1058. .water) - parseFloat(_priceList[i].detailList[j].water)) / 0.1 * parseFloat(_priceList[i]
  1059. .detailList[j + 1].jfprice))
  1060. }
  1061. _leftObj.priceList.push({
  1062. index: j,
  1063. priceStart: parseFloat(_priceList[i].detailList[j].water),
  1064. priceEnd: parseFloat(_priceList[i].detailList[j - 2].water),
  1065. type: parseFloat(_priceList[i].detailList[j].type),
  1066. water: _priceList[i].detailList[j].water,
  1067. jfprice: parseFloat(_priceList[i].detailList[j - 1].jfprice),
  1068. baseprice: baseprice,
  1069. price: (parseFloat(_priceList[i].detailList[j].water) - parseFloat(_priceList[i].detailList[j -
  1070. 2].water)) / 0.1 * parseFloat(_priceList[i].detailList[j - 1].jfprice)
  1071. })
  1072. }
  1073. }
  1074. }
  1075. }
  1076. // for (let j = (_priceList[i].detailList.length + 1) / 2 - 1; j > 0; j--) {
  1077. // if (_priceList[i].detailList[j] && _priceList[i].detailList[j].type != 4) {
  1078. // if (_priceList[i].detailList[j].type != 1) {
  1079. // let baseprice = ""
  1080. // if (j == (_priceList[i].detailList.length + 1) / 2 - 1) {
  1081. // baseprice = parseFloat(_priceList[i].basicUnitPrice)
  1082. // } else {
  1083. // baseprice = parseFloat(_priceList[i].basicUnitPrice + (parseFloat(_priceList[i].detailList[j + 2]
  1084. // .water) - parseFloat(_priceList[i].detailList[j].water)) / 0.5 * parseFloat(_priceList[i]
  1085. // .detailList[j + 1].jfprice))
  1086. // }
  1087. // _leftObj.priceList.push({
  1088. // index: j,
  1089. // priceStart: parseFloat(_priceList[i].detailList[j].water),
  1090. // priceEnd: parseFloat(_priceList[i].detailList[j - 2].water),
  1091. // type: parseFloat(_priceList[i].detailList[j].type),
  1092. // water: _priceList[i].detailList[j].water,
  1093. // jfprice: parseFloat(_priceList[i].detailList[j - 1].jfprice),
  1094. // baseprice: baseprice,
  1095. // price: (parseFloat(_priceList[i].detailList[j].water) - parseFloat(_priceList[i].detailList[j -
  1096. // 2].water)) / 0.5 * parseFloat(_priceList[i].detailList[j - 1].jfprice)
  1097. // })
  1098. // }
  1099. // }
  1100. // }
  1101. this.left.push(_leftObj)
  1102. console.log('this.left', this.left)
  1103. if(this.baseInfoForm.paramType == '2'){
  1104. for (let k = index; k <= _priceList[i].detailList.length; k++) {
  1105. if (_priceList[i].detailList[k] && _priceList[i].detailList[k].type != 4) {
  1106. if (_priceList[i].detailList[k].type != 3) {
  1107. let baseprice = ''
  1108. if (k == index) {
  1109. baseprice = parseFloat(_priceList[i].basicUnitPrice)
  1110. } else {
  1111. baseprice = parseFloat(parseFloat(_priceList[i].basicUnitPrice) - (parseFloat(_priceList[i].detailList[k]
  1112. .water) - parseFloat(_priceList[i].detailList[k - 2].water)) / 0.1 * parseFloat(_priceList[i]
  1113. .detailList[k - 1].jfprice))
  1114. }
  1115. _rightObj.priceList.push({
  1116. index: k,
  1117. priceStart: parseFloat(_priceList[i].detailList[k].water),
  1118. priceEnd: parseFloat(_priceList[i].detailList[k + 2].water),
  1119. type: parseFloat(_priceList[i].detailList[k].type),
  1120. water: _priceList[i].detailList[k].water,
  1121. jfprice: parseFloat(_priceList[i].detailList[k + 1].jfprice),
  1122. baseprice: baseprice,
  1123. price: (parseFloat(_priceList[i].detailList[k + 2].water) - parseFloat(_priceList[i].detailList[
  1124. k].water)) / 0.1 * parseFloat(_priceList[i].detailList[k + 1].jfprice)
  1125. })
  1126. }
  1127. }
  1128. }
  1129. }
  1130. else{
  1131. for (let k = 0; k <= _priceList[i].detailList.length; k++) {
  1132. if (_priceList[i].detailList[k] && _priceList[i].detailList[k].type != 4) {
  1133. if (_priceList[i].detailList[k].type != 3) {
  1134. let baseprice = ''
  1135. if (k == 0) {
  1136. baseprice = parseFloat(this.baseInfoForm.dryGrainPrice)
  1137. } else {
  1138. var waterCount = 0
  1139. for(var p=0;p<_rightObj.priceList.length;p++){
  1140. waterCount += (_rightObj.priceList[p].priceEnd - _rightObj.priceList[p].priceStart)*_rightObj.priceList[p].param/100
  1141. }
  1142. baseprice = parseFloat(parseFloat(this.baseInfoForm.dryGrainPrice) * ( 1- waterCount))
  1143. }
  1144. _rightObj.priceList.push({
  1145. index: k,
  1146. priceStart: parseFloat(_priceList[i].detailList[k].water),
  1147. priceEnd: parseFloat(_priceList[i].detailList[k + 2].water),
  1148. type: parseFloat(_priceList[i].detailList[k].type),
  1149. water: _priceList[i].detailList[k].water,
  1150. param:_priceList[i].detailList[k + 1].jfprice,
  1151. jfprice: parseFloat(this.baseInfoForm.dryGrainPrice * (parseFloat(_priceList[i].detailList[k + 2].water) - parseFloat(_priceList[i].detailList[
  1152. k].water))*parseFloat(_priceList[i].detailList[k + 1].jfprice)/100/((parseFloat(_priceList[i].detailList[k + 2].water) - parseFloat(_priceList[i].detailList[
  1153. k].water))/0.1)),
  1154. baseprice: baseprice,
  1155. price: (parseFloat(_priceList[i].detailList[k + 2].water) - parseFloat(_priceList[i].detailList[
  1156. k].water)) / 0.1 * parseFloat(_priceList[i].detailList[k + 1].jfprice)
  1157. })
  1158. }
  1159. }
  1160. }
  1161. }
  1162. // for (let k = (_priceList[i].detailList.length + 1) / 2 - 1; k <= _priceList[i].detailList.length; k++) {
  1163. // if (_priceList[i].detailList[k] && _priceList[i].detailList[k].type != 4) {
  1164. // if (_priceList[i].detailList[k].type != 3) {
  1165. // let baseprice = ""
  1166. // if (k == (_priceList[i].detailList.length + 1) / 2 - 1) {
  1167. // baseprice = parseFloat(_priceList[i].basicUnitPrice)
  1168. // } else {
  1169. // baseprice = parseFloat(_priceList[i].basicUnitPrice - (parseFloat(_priceList[i].detailList[k]
  1170. // .water) - parseFloat(_priceList[i].detailList[k - 2].water)) / 0.5 * parseFloat(_priceList[i]
  1171. // .detailList[k - 1].jfprice))
  1172. // }
  1173. // _rightObj.priceList.push({
  1174. // index: k,
  1175. // priceStart: parseFloat(_priceList[i].detailList[k].water),
  1176. // priceEnd: parseFloat(_priceList[i].detailList[k + 2].water),
  1177. // type: parseFloat(_priceList[i].detailList[k].type),
  1178. // water: _priceList[i].detailList[k].water,
  1179. // jfprice: parseFloat(_priceList[i].detailList[k + 1].jfprice),
  1180. // baseprice: baseprice,
  1181. // price: (parseFloat(_priceList[i].detailList[k + 2].water) - parseFloat(_priceList[i].detailList[
  1182. // k].water)) / 0.5 * parseFloat(_priceList[i].detailList[k + 1].jfprice)
  1183. // })
  1184. // }
  1185. // }
  1186. // }
  1187. this.right.push(_rightObj)
  1188. console.log('this.right', this.right)
  1189. }
  1190. }
  1191. },
  1192. // 获取当前价格左右价格区间数据
  1193. getOtherPrice(list, water, direction) {},
  1194. calculatePriceRight(_waterMax) {
  1195. //获取每个分界值
  1196. let _listResult = []
  1197. for (let i = 0; i < this.right.length; i++) {
  1198. let _list = this.right[i].priceList
  1199. let tmp = ''
  1200. for (let k = 0; k < _list.length; k++) {
  1201. if (_waterMax < _list[k].priceEnd && _waterMax >= _list[k].priceStart) {
  1202. tmp = parseFloat(_list[k].baseprice - _list[k].jfprice * (((_waterMax) - _list[k].priceStart) / 0.1))
  1203. }
  1204. }
  1205. _listResult.push(tmp)
  1206. }
  1207. return _listResult
  1208. },
  1209. // 计算价格
  1210. calculatePrice(_waterMax) {
  1211. let _listResult = []
  1212. for (let i = 0; i < this.left.length; i++) {
  1213. let _list = this.left[i].priceList
  1214. let tmp = ''
  1215. for (let k = 0; k < _list.length; k++) {
  1216. if (_waterMax >= _list[k].priceEnd && _waterMax < _list[k].priceStart) {
  1217. tmp = parseFloat(_list[k].baseprice + _list[k].jfprice * ((_list[k].priceStart - (_waterMax )) / 0.1))
  1218. }
  1219. }
  1220. _listResult.push(tmp)
  1221. }
  1222. return _listResult
  1223. },
  1224. // 构造查看粮价设置数据
  1225. makeLookPriceList() {
  1226. this.selectVal = this.baseInfoForm.goodsName
  1227. let _priceList = this.baseInfoForm.details
  1228. let _checkList = []
  1229. let _detailList = []
  1230. let _pointPrice = []
  1231. let _basePrice = 0
  1232. for (let i = 0; i < _priceList.length; i++) {
  1233. _checkList = _priceList[i].level.split(',')
  1234. _detailList = _priceList[i].point.split(',')
  1235. _pointPrice = _priceList[i].pointPrice.split(',')
  1236. let _newDetailList = []
  1237. for (let k = 0; k < _detailList.length; k++) {
  1238. let _obj = {}
  1239. if (_detailList[k] == this.baseInfoForm.waterMin) {
  1240. _obj = {
  1241. type: 1,
  1242. name: '干粮',
  1243. water: _detailList[k],
  1244. isWrite: false
  1245. }
  1246. } else if (_detailList[k] == this.baseInfoForm.waterMax) {
  1247. _obj = {
  1248. type: 3,
  1249. name: '上限',
  1250. water: _detailList[k],
  1251. isWrite: false
  1252. }
  1253. } else if (_detailList[k] == this.baseInfoForm.waterBase) {
  1254. _obj = {
  1255. type: 2,
  1256. name: '基准',
  1257. water: _detailList[k],
  1258. isWrite: false
  1259. }
  1260. } else {
  1261. _obj = {
  1262. name: '分界',
  1263. water: _detailList[k],
  1264. type: 5,
  1265. index: k,
  1266. isWrite: true
  1267. }
  1268. }
  1269. _newDetailList.push(_obj)
  1270. if (k != _detailList.length - 1) {
  1271. _newDetailList.push({
  1272. type: 4,
  1273. jfprice: _pointPrice[k]
  1274. })
  1275. }
  1276. }
  1277. let _obj = {
  1278. basicUnitPrice: _priceList[i].basePrice,
  1279. index: i,
  1280. checkList: _checkList,
  1281. detailList: _newDetailList
  1282. }
  1283. this.priceList.push(_obj)
  1284. }
  1285. }
  1286. },
  1287. }
  1288. </script>
  1289. <style lang="scss">
  1290. .el-table .warning-row {
  1291. background: oldlace;
  1292. }
  1293. .el-table .success-row {
  1294. background: #f0f9eb;
  1295. }
  1296. .el-checkbox__input.is-checked .el-checkbox__inner,
  1297. .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  1298. background-color: #5878E8;
  1299. border-color: #5878E8;
  1300. }
  1301. .el-checkbox__input.is-checked+.el-checkbox__label {
  1302. color: #5878E8;
  1303. }
  1304. .el-checkbox.is-bordered.is-checked {
  1305. border-color: #5878E8;
  1306. }
  1307. .el-checkbox__input.is-focus .el-checkbox__inner {
  1308. border-color: #5878E8;
  1309. }
  1310. .basic-container {
  1311. overflow: auto;
  1312. }
  1313. .container {
  1314. padding: 20px
  1315. }
  1316. /deep/.el-header {
  1317. padding: 0;
  1318. }
  1319. .header {
  1320. display: flex;
  1321. align-items: center;
  1322. border-bottom: 1px solid #E9ECF7;
  1323. padding-bottom: 10px;
  1324. width: 100%;
  1325. .head-icon {
  1326. width: 19px;
  1327. height: 19px;
  1328. margin-right: 10px;
  1329. }
  1330. .head-title {
  1331. font-size: 21px;
  1332. font-weight: 600;
  1333. color: #323233;
  1334. }
  1335. }
  1336. .row1,
  1337. .row2 {
  1338. // background: red;
  1339. display: flex;
  1340. // margin-right: 20px;
  1341. }
  1342. .row3 {
  1343. .top {
  1344. display: flex;
  1345. .btn {
  1346. width: 52px;
  1347. height: 24px;
  1348. background: #5878E8;
  1349. color: white;
  1350. margin-left: 20px;
  1351. display: flex;
  1352. align-items: center;
  1353. justify-content: center;
  1354. // text-align: center;
  1355. }
  1356. }
  1357. .title {
  1358. display: flex;
  1359. align-items: center;
  1360. border-left: 4px solid #5473E8;
  1361. font-size: 16px;
  1362. font-weight: 600;
  1363. color: #323233;
  1364. padding-left: 10px;
  1365. }
  1366. }
  1367. .base-info {
  1368. border-left: 4px solid #5473E8;
  1369. font-size: 16px;
  1370. font-weight: 600;
  1371. color: #323233;
  1372. padding-left: 10px;
  1373. margin: 24px 0 10px 0;
  1374. }
  1375. .grid-content {
  1376. margin-right: 20px;
  1377. }
  1378. .content {
  1379. border: 1px solid #D8DCE6;
  1380. margin: 20px 0;
  1381. padding: 15px;
  1382. border-radius: 4px;
  1383. .top {
  1384. display: flex;
  1385. justify-content: space-between;
  1386. .left {
  1387. display: flex;
  1388. align-items: center;
  1389. .text {
  1390. width: 220px;
  1391. font-size: 14px;
  1392. font-weight: 400;
  1393. color: #8890B1;
  1394. }
  1395. }
  1396. }
  1397. .level {
  1398. margin: 10px 0;
  1399. }
  1400. .count {
  1401. display: flex;
  1402. margin-bottom: 15px;
  1403. .left {
  1404. width: 10%;
  1405. display: flex;
  1406. flex-direction: column;
  1407. align-items: flex-end;
  1408. justify-content: flex-end;
  1409. line-height: 24px;
  1410. }
  1411. .right {
  1412. width: 85%;
  1413. position: relative;
  1414. padding-bottom: 50px;
  1415. .water-price {
  1416. width: 60px;
  1417. height: 30px;
  1418. background: #F6F7FB;
  1419. border-radius: 4px;
  1420. border: 1px solid #D8DCE6;
  1421. text-align: center
  1422. }
  1423. .add,
  1424. .reduce {
  1425. width: 16px;
  1426. height: 16px;
  1427. background: #5473E8;
  1428. border-radius: 2px;
  1429. color: white;
  1430. background: #5473E8;
  1431. border-radius: 2px;
  1432. color: white;
  1433. padding: 0 !important;
  1434. display: inline-flex;
  1435. justify-content: center;
  1436. align-items: center;
  1437. font-size: 14px;
  1438. }
  1439. .reduce {
  1440. background: white;
  1441. color: #D5D8DE;
  1442. border: 1px solid #D5D8DE;
  1443. display: inline-flex;
  1444. justify-content: center;
  1445. align-items: center;
  1446. }
  1447. .item-style {
  1448. position: relative;
  1449. .item-style-title {
  1450. margin-bottom: 10px;
  1451. text-align: center;
  1452. }
  1453. }
  1454. .line {
  1455. position: absolute;
  1456. top: 72px;
  1457. width: 100%;
  1458. height: 5px;
  1459. background: linear-gradient(39deg, #E6EEFF 0%, #91B0F5 42%, #5878E8 100%);
  1460. border-radius: 3px;
  1461. }
  1462. .bottom-price {
  1463. position: absolute;
  1464. bottom: -10px;
  1465. }
  1466. .jt-style {
  1467. position: absolute;
  1468. top: 64px;
  1469. width: 0px;
  1470. height: 0px;
  1471. right: -15px;
  1472. border-left: 15px solid #5473E8;
  1473. border-top: 10px solid transparent;
  1474. border-bottom: 10px solid transparent;
  1475. }
  1476. display: flex;
  1477. justify-content: space-between;
  1478. .circle {
  1479. position: absolute;
  1480. z-index: 2;
  1481. width: 15px;
  1482. height: 15px;
  1483. background: #FFFFFF;
  1484. border: 3px solid #5473E8;
  1485. border-radius: 50%;
  1486. right: 40%;
  1487. bottom: -22px
  1488. }
  1489. }
  1490. }
  1491. }
  1492. .submit {
  1493. float: right;
  1494. width: 74px;
  1495. height: 32px;
  1496. background: #5473E8;
  1497. color: white;
  1498. border-radius: 4px;
  1499. }
  1500. .page2-content {
  1501. border: 1px solid #D8DCE6;
  1502. margin-top: 20px;
  1503. padding: 10px;
  1504. box-sizing: border-box;
  1505. text-align: center;
  1506. border-radius: 4px;
  1507. padding-bottom: 20px;
  1508. }
  1509. .titel {
  1510. font-size: 20px;
  1511. font-weight: 500;
  1512. color: #323233;
  1513. margin: 20px;
  1514. }
  1515. .type {
  1516. font-size: 16px;
  1517. font-weight: 500;
  1518. color: #262626;
  1519. }
  1520. .double {
  1521. background: #FEFBF6 !important;
  1522. }
  1523. .single {
  1524. background: #F7FBFF !important;
  1525. }
  1526. .bottom-btn {
  1527. display: flex;
  1528. .left {
  1529. color: red;
  1530. }
  1531. margin: 20px 0;
  1532. justify-content: space-around;
  1533. align-items: center;
  1534. }
  1535. .white-bgc{
  1536. background: white!important;
  1537. }
  1538. #aaa::selection{
  1539. // background: red;
  1540. }
  1541. </style>