product.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  6. <link rel="stylesheet" href="../css/index.css">
  7. <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
  8. <script src="../js/babel.min.js"></script>
  9. <script src="../js/vue.js"></script>
  10. <script src="../js/axios.min.js"></script>
  11. <script src="../js/index.js"></script>
  12. <title>大卫博士-退货信息登记</title>
  13. <script type="text/javascript">
  14. document.addEventListener('plusready', function() {
  15. //console.log("所有plus api都应该在此事件发生后调用,否则会出现plus is undefined。")
  16. });
  17. </script>
  18. <style>
  19. * {
  20. margin: 0;
  21. padding: 0;
  22. }
  23. #app {
  24. /* width: 100%; */
  25. /* padding-top: 36px ; */
  26. height: 100%;
  27. color: #333;
  28. }
  29. .flex {
  30. display: flex;
  31. align-items: center;
  32. }
  33. .flexS {
  34. display: flex;
  35. align-items: center;
  36. justify-content: space-between;
  37. }
  38. .flexC {
  39. display: flex;
  40. justify-content: space-between;
  41. flex-direction: column;
  42. }
  43. .sanzhuang {
  44. font-size: 18px;
  45. font-weight: bold;
  46. padding: 0 15px;
  47. margin-top: 12px;
  48. }
  49. .sanzhuang-item {
  50. font-size: 15px;
  51. font-weight: 400;
  52. }
  53. .sanzhuang-bg {
  54. margin: 9px 15px 12px 15px;
  55. padding: 9px 15px 12px 15px;
  56. background: #F9F9FB;
  57. border-radius: 6px 6px 6px 6px;
  58. height: 168px;
  59. font-size: 15px;
  60. font-weight: bold;
  61. }
  62. .step {
  63. width: 90px;
  64. height: 27px;
  65. background: #F9F9FB;
  66. border-radius: 3px 3px 3px 3px;
  67. border: 1px solid #999999;
  68. }
  69. .countNum {
  70. flex: 1;
  71. overflow: hidden;
  72. border: none;
  73. text-align: center;
  74. line-height: 72rpx;
  75. height: 100%;
  76. }
  77. .step-one {
  78. width: 30%;
  79. line-height: 27px;
  80. text-align: center;
  81. border-right: 1px solid #999999;;
  82. }
  83. .step-two {
  84. width: 40%;
  85. line-height: 27px;
  86. text-align: center;
  87. }
  88. .step-three {
  89. width: 30%;
  90. line-height: 27px;
  91. border-left: 1px solid #999999;;
  92. text-align: center;
  93. }
  94. .bottom {
  95. padding: 12px 30px 72px 15px;
  96. }
  97. .bottom-item {
  98. margin-bottom: 12px;
  99. font-size: 15px;
  100. font-weight: bold;
  101. }
  102. .title {
  103. height: 42px;
  104. padding: 0 15px;
  105. display: flex;
  106. align-items: flex-end;
  107. }
  108. .title-span {
  109. font-size: 21px;
  110. font-weight: bold;
  111. margin-left: 5px;
  112. }
  113. .el-message-box {
  114. width: 350px
  115. }
  116. .el-message {
  117. width: 350px
  118. }
  119. .fixed {
  120. position: fixed;
  121. top: 0;
  122. left: 0;
  123. width: 100%;
  124. background-color: #fff;
  125. }
  126. .tabBar {
  127. height: 40px;
  128. display: flex;
  129. align-items: center;
  130. padding: 0 15px;
  131. }
  132. .tabBar-span {
  133. font-size: 15px;
  134. margin-left: 5px;
  135. }
  136. .topFlex {
  137. display: flex;
  138. align-items: center;
  139. }
  140. .bg {
  141. background: #FFF4F3;
  142. }
  143. .topFlex-item {
  144. width: 20%;
  145. line-height: 42px;
  146. font-size: 18px;
  147. font-weight: bold;
  148. text-align: center;
  149. }
  150. .height {
  151. line-height: 50px !important;
  152. }
  153. .scollH {
  154. height: 210px;
  155. overflow: scroll;
  156. }
  157. .list {
  158. padding: 175px 0 0px 0;
  159. border-bottom: 9px solid #F2F2F2;
  160. }
  161. .list-item {
  162. display: flex;
  163. justify-content: space-between;
  164. align-items: center;
  165. line-height: 42px;
  166. padding: 0 15px 0 0;
  167. }
  168. .list-span {
  169. font-size: 15px;
  170. font-weight: bold;
  171. width: 20%;
  172. text-align: center;
  173. }
  174. .list-del {
  175. width: 57px;
  176. line-height: 28px;
  177. background: linear-gradient(93deg, #FF5824 0%, #FF4444 100%);
  178. border-radius: 15px;
  179. text-align: center;
  180. color: #fff;
  181. font-size: 15px;
  182. }
  183. .back {
  184. background-color: #F8F8F8;
  185. }
  186. .flexBotom {
  187. position: fixed;
  188. bottom: 0;
  189. left: 0;
  190. width: 100%;
  191. height: 61px;
  192. background: #FFFFFF;
  193. box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.16);
  194. display: flex;
  195. align-items: center;
  196. justify-content: center;
  197. }
  198. .flexBotom-btn {
  199. width: 327px;
  200. line-height: 47px;
  201. background: linear-gradient(93deg, #A080FF 0%, #5D6BFF 100%);
  202. border-radius: 33px;
  203. text-align: center;
  204. color: #fff;
  205. font-size: 18px;
  206. }
  207. </style>
  208. </head>
  209. <body>
  210. <div id="app">
  211. <div v-loading.fullscreen.lock="loadingFull" />
  212. <div class="fixed">
  213. <div class="tabBar">
  214. <img src="../img/back.png" style="width: 17px;height: 12px;">
  215. <span class="tabBar-span" @click="goBack">返回</span>
  216. </div>
  217. <div class="title">
  218. <div style="display: flex;align-items: center;">
  219. <img src="../img/bao.png" style="width: 20px;height: 17px;">
  220. <span class="title-span" @click="goBack">整套</span>
  221. </div>
  222. </div>
  223. <div class="topFlex">
  224. <div class="topFlex-item height" v-for="(item, index) in list" :key="index">
  225. {{item}}
  226. </div>
  227. </div>
  228. <div class="topFlex bg">
  229. <div class="topFlex-item" v-for="(item, index) in numList" :key="index">
  230. {{ item }}
  231. </div>
  232. </div>
  233. </div>
  234. <div class="list" :class="productList.length>4 ? 'scollH' : ''">
  235. <div class="list-item" :class="(index + 1)%2 == 0 ? 'back' : ''" v-for="(item, index) in productList" :key="index">
  236. <div class="list-span">{{ item.name }}</div>
  237. <div class="list-span">{{ item.type }}</div>
  238. <div class="list-span">{{ item.size }}</div>
  239. <div class="list-span">{{ item.num }}</div>
  240. <div class="list-del" @click="del(index)">
  241. 删除
  242. </div>
  243. </div>
  244. </div>
  245. <div class="title">
  246. <div style="display: flex;align-items: center;">
  247. <img src="../img/neiku.png" style="width: 21px;height: 21px;">
  248. <span class="title-span" @click="goBack">散装</span>
  249. </div>
  250. </div>
  251. <div class="sanzhuang flexS" @click="showChuan=!showChuan">
  252. <span>已穿</span>
  253. <div class="sanzhuang-item flex">
  254. <span>{{ allchuanNum }}条</span>
  255. <img :src="showChuan?image[0]:image[1]" style="width: 20px;height: 17px;margin-left: 12px;" >
  256. </div>
  257. </div>
  258. <div v-show="showChuan" class="sanzhuang-bg flexC">
  259. <div v-for="(item,i) in list" :key="i" class="flexS">
  260. <div class="sanzhuang-name">{{ item }}版(条)</div>
  261. <div class="step flexS">
  262. <div class="step-one" @click="minus(1, i)">-</div>
  263. <input
  264. v-model="chuanNum[i]"
  265. class="countNum"
  266. @focus="inputClear(0, i)"
  267. @blur="inputCountNum(0, i)"
  268. type="number"
  269. onkeyup="this.value=this.value.replace(/\D/g,'')" onpaste="this.value=this.value.replace(/\D/g,'')"
  270. />
  271. <div class="step-three" @click="add(1, i)">+</div>
  272. </div>
  273. </div>
  274. </div>
  275. <div class="sanzhuang flexS" @click="showWei=!showWei">
  276. <span>未穿</span>
  277. <div class="sanzhuang-item flex">
  278. <span>{{ allWeiNum }}条</span>
  279. <img :src="showWei?image[0]:image[1]" style="width: 20px;height: 17px;margin-left: 12px;" >
  280. </div>
  281. </div>
  282. <div v-show="showWei" class="sanzhuang-bg flexC">
  283. <div v-for="(item,i) in list" :key="i" class="flexS">
  284. <div class="sanzhuang-name">{{ item }}版(条)</div>
  285. <div class="step flexS">
  286. <div class="step-one" @click="minus(0, i)">-</div>
  287. <input
  288. v-model="weiNum[i]"
  289. class="countNum"
  290. @focus="inputClear(1, i)"
  291. @blur="inputCountNum(1, i)"
  292. type="number"
  293. onkeyup="this.value=this.value.replace(/\D/g,'')" onpaste="this.value=this.value.replace(/\D/g,'')"
  294. />
  295. <div class="step-three" @click="add(0, i)">+</div>
  296. </div>
  297. </div>
  298. </div>
  299. <div class="title">
  300. <div style="display: flex;align-items: center;">
  301. <img src="../img/peijian.png" style="width: 22px;height: 22px;">
  302. <span class="title-span" @click="goBack">配件</span>
  303. </div>
  304. </div>
  305. <div class="bottom">
  306. <div class="bottom-item flexS">
  307. <div>缺少肥皂(块)</div>
  308. <div class="step flexS">
  309. <div class="step-one" @click="minus(2, 0)">-</div>
  310. <input
  311. v-model="zaoNum"
  312. class="countNum"
  313. @focus="inputClear(2)"
  314. @blur="inputCountNum(2)"
  315. type="number"
  316. onkeyup="this.value=this.value.replace(/\D/g,'')" onpaste="this.value=this.value.replace(/\D/g,'')"
  317. />
  318. <div class="step-three" @click="add(2, 0)">+</div>
  319. </div>
  320. </div>
  321. <div class="bottom-item flexS">
  322. <div>缺少手提袋(个)</div>
  323. <div class="step flexS">
  324. <div class="step-one" @click="minus(3, 0)">-</div>
  325. <input
  326. v-model="daiNum"
  327. class="countNum"
  328. @focus="inputClear(3)"
  329. @blur="inputCountNum(3)"
  330. type="number"
  331. onkeyup="this.value=this.value.replace(/\D/g,'')" onpaste="this.value=this.value.replace(/\D/g,'')"
  332. />
  333. <div class="step-three" @click="add(3, 0)">+</div>
  334. </div>
  335. </div>
  336. </div>
  337. <div class="flexBotom">
  338. <div class="flexBotom-btn" @click="noMultipleClicks(submit)">
  339. 提交
  340. </div>
  341. </div>
  342. </div>
  343. <script type="text/babel">
  344. var app = new Vue({
  345. el: '#app',
  346. data() {
  347. return {
  348. loadingFull: false,
  349. type: 0,
  350. num: '',
  351. mask: true,
  352. noClick: true,
  353. list: ['精装', '简约', '纯棉', '高腰', '青春'],
  354. productList: [],
  355. numList: [0, 0, 0, 0, 0],
  356. image: [
  357. '../img/xia.png',
  358. '../img/right.png'
  359. ],
  360. num: 4,
  361. showWei: false,
  362. showChuan: false,
  363. allWeiNum: 0,
  364. allchuanNum: 0,
  365. weiNum: [0, 0, 0, 0, 0],
  366. chuanNum: [0, 0, 0, 0, 0],
  367. zaoNum: 0,
  368. daiNum: 0
  369. }
  370. },
  371. mounted() {
  372. var url = location.search //获取url中"?"符后的字串
  373. if (url.indexOf("?") != -1) {
  374. var str = url.substr(1)
  375. var strs = str.split("=")
  376. this.id = strs[1]
  377. }
  378. this.productList = JSON.parse(window.localStorage.getItem("productList"))
  379. if(this.productList) {
  380. this.countNum(this.productList)
  381. }
  382. },
  383. methods: {
  384. inputCountNum(type, i) {
  385. if (type == 0) {
  386. this.chuanNum[i] = this.chuanNum[i] == ''?0:this.chuanNum[i]
  387. this.chuanNum = JSON.parse(JSON.stringify(this.chuanNum))
  388. this.allchuanNum = eval(this.chuanNum.join("+"))
  389. } else if (type == 1) {
  390. this.weiNum[i] = this.weiNum[i] == ''?0:this.weiNum[i]
  391. this.weiNum = JSON.parse(JSON.stringify(this.weiNum))
  392. this.allWeiNum = eval(this.weiNum.join("+"))
  393. } else if (type == 2) {
  394. this.zaoNum = this.zaoNum == ''?0:this.zaoNum
  395. this.zaoNum = JSON.parse(JSON.stringify(this.zaoNum))
  396. } else if (type == 3) {
  397. this.daiNum = this.daiNum == ''?0:this.daiNum
  398. this.daiNum = JSON.parse(JSON.stringify(this.daiNum))
  399. }
  400. },
  401. inputClear(type, i) {
  402. if (type == 0) {
  403. this.chuanNum[i] = ''
  404. this.chuanNum = JSON.parse(JSON.stringify(this.chuanNum))
  405. } else if (type == 1) {
  406. this.weiNum[i] = ''
  407. this.weiNum = JSON.parse(JSON.stringify(this.weiNum))
  408. } else if (type == 2) {
  409. this.zaoNum= ''
  410. } else if (type == 3) {
  411. this.daiNum= ''
  412. }
  413. },
  414. minus(type, i) {
  415. if (type == 0) {
  416. if (this.weiNum[i] == 0) {
  417. return
  418. }
  419. this.weiNum[i] --
  420. this.allWeiNum --
  421. this.weiNum = JSON.parse(JSON.stringify(this.weiNum))
  422. } else if (type == 1) {
  423. if (this.chuanNum[i] == 0) {
  424. return
  425. }
  426. this.chuanNum[i] --
  427. this.allchuanNum --
  428. this.chuanNum = JSON.parse(JSON.stringify(this.chuanNum))
  429. } else if (type == 2) {
  430. if (this.zaoNum == 0) {
  431. return
  432. }
  433. this.zaoNum --
  434. } else {
  435. if (this.daiNum == 0) {
  436. return
  437. }
  438. this.daiNum --
  439. }
  440. },
  441. add(type, i) {
  442. if (type == 0) {
  443. this.weiNum[i] ++
  444. this.allWeiNum ++
  445. this.weiNum = JSON.parse(JSON.stringify(this.weiNum))
  446. } else if (type == 1) {
  447. this.chuanNum[i] ++
  448. this.allchuanNum ++
  449. this.chuanNum = JSON.parse(JSON.stringify(this.chuanNum))
  450. } else if (type == 2) {
  451. this.zaoNum ++
  452. } else {
  453. this.daiNum ++
  454. }
  455. },
  456. preventKeyBord(e) {
  457. e.target.setAttribute("readonly", true);
  458. setTimeout(() => {
  459. e.target.removeAttribute("readonly")
  460. }, 100)
  461. },
  462. goBack() {
  463. window.history.back()
  464. },
  465. countNum(list) {
  466. let numList = [0, 0, 0, 0, 0]
  467. list.forEach(v => {
  468. if (v.name === '精装版') {
  469. numList[0] += v.num
  470. } else if (v.name === '简约版') {
  471. numList[1] += v.num
  472. } else if (v.name === '纯棉版') {
  473. numList[2] += v.num
  474. } else if (v.name === '高腰版') {
  475. numList[3] += v.num
  476. } else if (v.name === '青春版') {
  477. numList[4] += v.num
  478. }
  479. })
  480. this.numList = numList
  481. },
  482. del(i) {
  483. this.productList.splice(i, 1)
  484. this.countNum(this.productList)
  485. if (this.productList.length === 0) {
  486. window.localStorage.removeItem('productList')
  487. } else {
  488. window.localStorage.setItem('productList', JSON.stringify(this.productList))
  489. }
  490. },
  491. submit(row) {
  492. if(!this.productList || this.productList.length === 0) {
  493. this.$message.error('未登记信息')
  494. return
  495. }
  496. let data = this.productList
  497. let oldData = []
  498. data.forEach(item => {
  499. var oldObj = {
  500. good_name: item.name,
  501. list: []
  502. }
  503. oldObj.list.push({
  504. num: Number(item.num),
  505. size: item.size,
  506. sex: item.type === '男款' || item.type === '男'? 1 : 0,
  507. time: item.time
  508. })
  509. oldData.push(oldObj)
  510. })
  511. var newData = []
  512. var newObj = {}
  513. oldData.forEach((el, i) => {
  514. if (!newObj[el.good_name]) {
  515. newData.push(el);
  516. newObj[el.good_name] = true;
  517. } else {
  518. newData.forEach(el => {
  519. if (el.good_name === oldData[i].good_name) {
  520. let data = el.list.concat(oldData[i].list)
  521. // 重复合并,num相加
  522. for(let i=0; i<data.length; i++){
  523. for(let j=i+1; j<data.length; j++){
  524. if(data[i].size === data[j].size && data[i].sex === data[j].sex && data[i].time === data[j].time){
  525. // console.log('重复',data[i],data[j])
  526. data[i].num = data[i].num + data[j].num
  527. data.splice(j,1)
  528. }
  529. }
  530. }
  531. el.list = data
  532. }
  533. })
  534. }
  535. })
  536. console.log(newData)
  537. const arr = this.chuanNum
  538. const brr = this.weiNum
  539. const wear = {
  540. hard: arr[0],
  541. simple: arr[1],
  542. old_new: arr[2],
  543. old: arr[3],
  544. youth: arr[4]
  545. }
  546. const not_wear = {
  547. hard: brr[0],
  548. simple: brr[1],
  549. old_new: brr[2],
  550. old: brr[3],
  551. youth: brr[4]
  552. }
  553. this.$confirm('确定要提交吗 ?', '提示', {
  554. confirmButtonText: '确定',
  555. cancelButtonText: '取消',
  556. type: 'warning'
  557. })
  558. .then(() => {
  559. this.loadingFull = true
  560. let _this = this
  561. let total = eval(_this.numList.join("+"))
  562. axios.post('http://api.admin.app.cliu.cc/api/ReturnGood/InsertGoodInfo', {
  563. id: _this.id,
  564. total: total,
  565. info: newData,
  566. wear,
  567. not_wear,
  568. lack_soap: _this.zaoNum,
  569. lack_tote: _this.daiNum
  570. }).then(res => {
  571. _this.loadingFull = false
  572. if (res.code === 200) {
  573. window.ELEMENT.Message.success({
  574. message : '提交成功',
  575. duration: 800,
  576. offset: 80,
  577. onClose: () => {
  578. window.localStorage.removeItem('productList')
  579. window.location.href = "../index.html"
  580. }
  581. })
  582. } else {
  583. _this.$message.error(res.message || '提交失败')
  584. }
  585. }).catch((err) => {
  586. _this.$message.error('提交失败')
  587. _this.loadingFull = false
  588. })
  589. })
  590. .catch(() => {})
  591. },
  592. // 防连点
  593. noMultipleClicks(methods) {
  594. let that = this;
  595. if (that.noClick) {
  596. that.noClick= false;
  597. methods();
  598. setTimeout(function () {
  599. that.noClick= true;
  600. }, 1500)
  601. }
  602. },
  603. }
  604. })
  605. </script>
  606. </body>
  607. </html>