cup.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. <template>
  2. <view class="container">
  3. <uni-section title="原料" type="line" padding>
  4. <uni-grid :column="2" :highlight="true">
  5. <uni-grid-item v-for="(item, index) in categoryList" :index="index" :key="index" style="height:400px;">
  6. <view class="grid-item-box" style="background-color: #fff;text-align:center;margin:10px 0;"
  7. @click="inputDialogToggle(item)">
  8. <text class="text">{{item.mtrName||'空'}}</text>
  9. <view class="progressContainer">
  10. <view class="progress" :style="{ height: Math.round(item.mtrResidue) + '%' }"
  11. v-if="item.exprStatus==='0'">
  12. <view class="progress-view"></view>
  13. </view>
  14. <view class="progress"
  15. :style="{ height: Math.round(item.mtrResidue) + '%', backgroundColor:'#ff0000'}" v-else>
  16. <view class="progress-view"></view>
  17. </view>
  18. <text class="expMsg" v-if="item.exprCloseStatus==='1' && item.exprStatus==='0' ">即将到期</text>
  19. <text class="errMsg" v-if="parseInt(item.mtrResidue) <= parseInt(item.residueWarn)">原料不足</text>
  20. <text class="tip">{{parseInt(item.mtrResidue) || '0'}}个</text>
  21. </view>
  22. <view class="num">
  23. <uni-badge class="uni-badge-left-margin" :text="item.barrelCode" type="primary"
  24. :customStyle="{background: '#00ffff', width: '60rpx',height:'60rpx',lineHeight:'60rpx',minWidth:'30rpx',fontSize:'40rpx'}" />
  25. </view>
  26. </view>
  27. </uni-grid-item>
  28. </uni-grid>
  29. </uni-section>
  30. <uni-section title="操作记录" type="line" padding>
  31. <uni-list>
  32. <uni-list-item title="时间"></uni-list-item>
  33. </uni-list>
  34. <uni-table border stripe emptyText="暂无更多数据">
  35. <!-- 表头行 -->
  36. <uni-tr>
  37. <uni-th align="center">料筒</uni-th>
  38. <uni-th align="center">剩余原料</uni-th>
  39. <uni-th align="center">余量</uni-th>
  40. <uni-th align="center">换料原料</uni-th>
  41. <uni-th align="center">换料规格</uni-th>
  42. <uni-th align="center">到期日期</uni-th>
  43. </uni-tr>
  44. <uni-tr v-for="(item, index) in records" :key="item.id">
  45. <uni-td align="center">{{item.barrelCode||''}}</uni-td>
  46. <uni-td align="center">{{item.mtName||'空'}}</uni-td>
  47. <uni-td align="center">{{item.surplus||'0'}}</uni-td>
  48. <uni-td align="center">{{item.mtrName||'空'}}</uni-td>
  49. <uni-td align="center">{{item.specs||'0'}}</uni-td>
  50. <uni-td align="center">{{item.date||''}}</uni-td>
  51. </uni-tr>
  52. </uni-table>
  53. <!--<uni-table border stripe emptyText="暂无更多数据" v-show="false">
  54. <uni-tr>
  55. <uni-th align="center"></uni-th>
  56. <uni-th align="center">原料</uni-th>
  57. <uni-th align="center">规格</uni-th>
  58. <uni-th align="center">到期日期</uni-th>
  59. </uni-tr>
  60. <uni-tr v-for="(item, index) in records2" :key="item.id">
  61. <uni-td align="center">{{item.status===0?'修正前':'修正后'}}</uni-td>
  62. <uni-td align="center">{{item.name}}</uni-td>
  63. <uni-td align="center">{{item.specs}}</uni-td>
  64. <uni-td align="center">{{item.date}}</uni-td>
  65. </uni-tr>
  66. </uni-table>-->
  67. <uni-load-more status="more"></uni-load-more>
  68. </uni-section>
  69. <view class="inputBox" v-show="popShow" style="min-width:800rpx;">
  70. <uni-popup ref="inputDialog" type="dialog">
  71. <view class="popup">
  72. <uni-row class="uni-row">
  73. <uni-col :span="12">
  74. <view class="demo-uni-col dark">料筒</view>
  75. </uni-col>
  76. <uni-col :span="12">
  77. <view class="uni-col light">{{material.barrelCode}}</view>
  78. </uni-col>
  79. </uni-row>
  80. <uni-row class="uni-row">
  81. <uni-col :span="12">
  82. <view class="uni-col dark">产品</view>
  83. </uni-col>
  84. <uni-col :span="12">
  85. <view class="uni-col light">{{material.mtrName || '空'}}</view>
  86. </uni-col>
  87. </uni-row>
  88. <uni-row class="uni-row">
  89. <uni-col :span="12">
  90. <view class="uni-col dark">原料剩余</view>
  91. </uni-col>
  92. <uni-col :span="12">
  93. <view class="uni-col light">{{parseInt(material.mtrResidue) || '0'}}个
  94. ({{material.mtrResidue > material.residueWarn?'原料充足':'原料不足' }})</view>
  95. </uni-col>
  96. </uni-row>
  97. <uni-row class="uni-row">
  98. <uni-col :span="12">
  99. <view class="uni-col dark">过期状态</view>
  100. </uni-col>
  101. <uni-col :span="12">
  102. <view class="uni-col light">{{material.exprStatus==='0'?'正常':'过期'}}</view>
  103. </uni-col>
  104. </uni-row>
  105. <uni-row class="uni-row">
  106. <uni-col :span="12">
  107. <view class="uni-col dark">到期日期</view>
  108. </uni-col>
  109. <uni-col :span="12">
  110. <view class="uni-col light">{{material.exprTime||'空'}}</view>
  111. </uni-col>
  112. </uni-row>
  113. <uni-row class="uni-row">
  114. <uni-col :span="12">
  115. <button @click="editDialog(material)" type="primary" size="mini">换料</button>
  116. </uni-col>
  117. <uni-col :span="12">
  118. <button @click="dialogClose" type="primary" size="mini">关闭</button>
  119. </uni-col>
  120. </uni-row>
  121. </view>
  122. </uni-popup>
  123. </view>
  124. <view class="editBox" v-show="editShow">
  125. <!--<MaterialDetail ref="edit" :dialog-visible="editShow" @close="editClose" ></MaterialDetail>-->
  126. <uni-popup ref="editDialog" type="dialog">
  127. <view class="popup">
  128. <uni-forms class="uni-forms" :modelValue="form">
  129. <uni-forms-item class="form-item" label="料筒" name="barrelCode">
  130. <!--<text>{{this.form.barrelCode||'空'}}</text>-->
  131. <text style="line-height: 25px;height:25px;">{{form.barrelCode}}</text>
  132. </uni-forms-item>
  133. <uni-forms-item class="form-item" label="到期日期" name="date">
  134. <uni-datetime-picker type="date" v-model="form.date" />
  135. </uni-forms-item>
  136. <uni-forms-item class="form-item" label="剩余原料" name="currentMaterial">
  137. <text style="line-height: 25px;height:25px;">{{form.mtName||'空'}}</text>
  138. </uni-forms-item>
  139. <uni-forms-item class="form-item" label="余量" name="surplus">
  140. <uni-number-box :min="0" :max="100" v-model="form.surplus" :disabled="true">
  141. </uni-number-box>
  142. </uni-forms-item>
  143. <uni-forms-item class="form-item" label="加料" name="specs">
  144. <uni-number-box :min="0" :max="100" v-model="form.specs"></uni-number-box>
  145. </uni-forms-item>
  146. </uni-forms>
  147. <uni-row class="uni-row" style="margin-top: 200rpx">
  148. <uni-col :span="12">
  149. <button @click="update" type="primary" size="mini">确定</button>
  150. </uni-col>
  151. <uni-col :span="12">
  152. <button @click="editClose" type="primary" size="mini">关闭</button>
  153. </uni-col>
  154. </uni-row>
  155. </view>
  156. </uni-popup>
  157. </view>
  158. </view>
  159. </template>
  160. <script>
  161. const util = require("@/utils/util.js");
  162. const api = require('@/utils/api.js');
  163. export default {
  164. data() {
  165. return {
  166. index: 0,
  167. index2: 0,
  168. array: [1, 2, 3, 4, 5, 6, 7, 8, 9],
  169. specs: [5, 10, 20],
  170. popShow: false,
  171. editShow: false,
  172. materials: ['燕麦', '魔芋粉', '牛肉粉', '红薯粉', '蜂蜜'],
  173. material: {
  174. equId: '',
  175. barrelCode: '',
  176. mtrName: '',
  177. surplus: '',
  178. specs: '',
  179. date: '',
  180. status: ''
  181. },
  182. form: {
  183. materialId: '',
  184. equId: '',
  185. barrelCode: '',
  186. currentMaterial: '',
  187. mtName: '',
  188. replaceMaterial: '',
  189. surplus: '',
  190. specs: '',
  191. date: ''
  192. },
  193. records: [],
  194. records2: [{
  195. id: 1,
  196. name: '燕麦',
  197. surplus: '2',
  198. specs: '10',
  199. date: '2021-11-14 12:13',
  200. status: 0,
  201. }, {
  202. id: 2,
  203. name: '燕麦',
  204. surplus: '2',
  205. specs: '10',
  206. date: '2021-11-14 12:13',
  207. status: 1,
  208. }],
  209. rangeIds: [{
  210. value: 1,
  211. text: "1"
  212. },
  213. {
  214. value: 2,
  215. text: "2"
  216. },
  217. {
  218. value: 3,
  219. text: "3"
  220. }
  221. ],
  222. queryParams: util.initQueryParams(),
  223. totalPages: 1,
  224. rangeSurplus: [{
  225. value: 1,
  226. text: "5"
  227. },
  228. {
  229. value: 2,
  230. text: "10"
  231. },
  232. {
  233. value: 3,
  234. text: "20"
  235. }
  236. ],
  237. rangeSpecs: [{
  238. value: 1,
  239. text: "5"
  240. },
  241. {
  242. value: 2,
  243. text: "10"
  244. },
  245. {
  246. value: 3,
  247. text: "20"
  248. }
  249. ],
  250. rangeDates: [{
  251. value: "2021-11-14",
  252. text: "2021-11-14"
  253. },
  254. {
  255. value: "2021-12-24",
  256. text: "2021-12-24"
  257. },
  258. {
  259. value: "2022-08-01",
  260. text: "2022-08-01"
  261. }
  262. ],
  263. categoryList: [{
  264. id: 1,
  265. barrleCode: 1,
  266. mtrName: "燕麦",
  267. mtrResidue: 40,
  268. status: 1,
  269. exprStatus: '0',
  270. errMsg: '原料不足',
  271. }, {
  272. id: 2,
  273. barrleCode: 2,
  274. mtrName: "魔芋粉",
  275. mtrResidue: 60,
  276. status: 1,
  277. exprStatus: '0',
  278. errMsg: '即将过期',
  279. }, {
  280. id: 3,
  281. barrleCode: 3,
  282. mtrName: "红薯粉",
  283. mtrResidue: 80,
  284. exprStatus: '1',
  285. status: 0,
  286. errMsg: '',
  287. }, {
  288. id: 4,
  289. barrleCode: 4,
  290. mtrName: "牛肉粉",
  291. mtrResidue: 65,
  292. exprStatus: '0',
  293. status: 0,
  294. errMsg: '',
  295. }, {
  296. id: 5,
  297. barrleCode: 5,
  298. mtrName: "蜂蜜",
  299. mtrResidue: 40,
  300. exprStatus: '1',
  301. status: 0,
  302. errMsg: '',
  303. }, {
  304. id: 6,
  305. barrleCode: 6,
  306. mtrName: "安赛蜜",
  307. mtrResidue: 60,
  308. status: 0,
  309. exprStatus: '0',
  310. errMsg: '',
  311. }, {
  312. id: 7,
  313. barrleCode: 7,
  314. mtrName: "牛奶",
  315. mtrResidue: 80,
  316. status: 0,
  317. exprStatus: '1',
  318. errMsg: '',
  319. }, {
  320. id: 8,
  321. barrleCode: 8,
  322. mtrName: "橙汁",
  323. mtrResidue: 65,
  324. exprStatus: '0',
  325. status: 0,
  326. errMsg: '',
  327. }],
  328. }
  329. },
  330. components: {
  331. //MaterialDetail
  332. },
  333. methods: {
  334. inputDialogToggle(row) {
  335. //if (row.mtrResidue) {
  336. this.popShow = true
  337. this.$refs.inputDialog.open()
  338. //this.$refs.detail.setMaterial(row);
  339. this.material = row;
  340. //}
  341. },
  342. dialogClose() {
  343. this.popShow = false
  344. this.$refs.inputDialog.close()
  345. },
  346. editDialog(row) {
  347. this.dialogClose()
  348. this.editShow = true
  349. this.form = {
  350. 'barrelType': row.barrelType,
  351. 'materialId': row.id,
  352. 'currentMaterial': row.mtrId,
  353. 'replaceMaterial': row.mtrId,
  354. 'mtName': row.mtrName,
  355. 'surplus': row.mtrResidue,
  356. 'date': row.exprTime,
  357. 'barrelCode': row.barrelCode,
  358. 'equId': row.equId
  359. }
  360. this.$refs.editDialog.open()
  361. //this.$refs.edit.setMaterial(row);
  362. //console.log(this.form)
  363. },
  364. editClose() {
  365. this.editShow = false
  366. },
  367. getMaterialData(equId) {
  368. let that = this;
  369. util.request(api.MaterialList, {
  370. equId: equId,
  371. barrelType: '1'
  372. }, 'GET', 'application/json').then(function(res) {
  373. if (res.code === 0) {
  374. that.categoryList = res.data.records;
  375. }
  376. });
  377. },
  378. getRecordList(equId) {
  379. let that = this;
  380. that.queryParams.model.equId = equId
  381. that.queryParams.model.barrelType = "1"
  382. util.request(api.RecordList, that.queryParams, 'Post', 'application/json').then(function(res) {
  383. if (res.code === 0) {
  384. that.records = that.records.concat(res.data.records)
  385. that.totalPages = res.data.pages
  386. }
  387. });
  388. },
  389. update() {
  390. let that = this;
  391. let pages = getCurrentPages();
  392. let page = pages[pages.length - 1].$page.fullPath;
  393. let equId = page.split('equId=')[1]
  394. equId = equId? equId: ""
  395. util.request(api.CupRecordAdd, this.form, "POST", "application/json").then(function(res) {
  396. if (res.code === 0) {
  397. uni.showToast({
  398. title: "操作结果",
  399. icon: 'success',
  400. duration: 1000,
  401. complete: function() {
  402. setTimeout(function() {
  403. that.editClose()
  404. uni.reLaunch({
  405. url: '/pages/material/cup?equId='+equId,
  406. });
  407. }, 2000)
  408. }
  409. });
  410. } else {
  411. util.toast(res.data);
  412. }
  413. });
  414. },
  415. onReachBottom: function() {
  416. let pages = getCurrentPages();
  417. let page = pages[pages.length - 1].$page.fullPath;
  418. let equId = page.split('equId=')[1]
  419. equId = equId? equId: ""
  420. if (this.totalPages > this.queryParams.current) {
  421. this.queryParams.current = this.queryParams.current + 1
  422. } else {
  423. return false;
  424. }
  425. this.getRecordList(equId)
  426. },
  427. onLoad: function(option) {
  428. let equId = option.equId? option.equId : ""
  429. this.getMaterialData(equId);
  430. this.getRecordList(equId);
  431. }
  432. }
  433. }
  434. </script>
  435. <style style="scss">
  436. .grid-item-box .text {
  437. padding: 20rpx 0;
  438. height: 30rpx;
  439. line-height: 30rpx;
  440. font-weight: bold;
  441. width: inherit;
  442. }
  443. .grid-item-box .num {
  444. position: relative;
  445. margin: 0 auto;
  446. z-index: 999;
  447. }
  448. .grid-item-box .tip {
  449. position: absolute;
  450. bottom: 20rpx;
  451. left: 30%;
  452. margin: 0 auto;
  453. color: #fff;
  454. z-index: 999;
  455. text-align: center;
  456. }
  457. .grid-item-box .errMsg {
  458. position: absolute;
  459. left: 28%;
  460. top: 180rpx;
  461. font-size: 36rpx;
  462. width: 80rpx;
  463. color: #f0ad4e;
  464. z-index: 9999;
  465. margin: 0 auto;
  466. }
  467. .grid-item-box .expMsg {
  468. position: absolute;
  469. left: 28%;
  470. top: 60rpx;
  471. font-size: 36rpx;
  472. width: 80rpx;
  473. color: #f0ad4e;
  474. z-index: 9999;
  475. margin: 0 auto;
  476. }
  477. .fb-type {
  478. height: 104rpx;
  479. width: 75%;
  480. margin-left: 20%;
  481. background: #fff;
  482. margin-bottom: 20rpx;
  483. display: flex;
  484. flex-direction: row;
  485. align-items: center;
  486. padding-left: 30rpx;
  487. padding-right: 30rpx;
  488. }
  489. .fb-type .type-label {
  490. height: 36rpx;
  491. flex: 1;
  492. color: #333;
  493. font-size: 28rpx;
  494. }
  495. .fb-type .type-icon {
  496. height: 36rpx;
  497. width: 36rpx;
  498. }
  499. .popup-content {
  500. align-items: center;
  501. justify-content: center;
  502. padding: 15px;
  503. height: 50px;
  504. background-color: #fff;
  505. }
  506. .popup {
  507. display: block;
  508. padding: 5rpx 10rpx 0;
  509. overflow: hidden;
  510. background-color: #fff;
  511. }
  512. .uni-row {
  513. margin-bottom: 10px;
  514. display: block;
  515. }
  516. .uni-col {
  517. height: 36px;
  518. border-radius: 5px;
  519. text-align: center;
  520. }
  521. .fb-type {
  522. height: 84rpx;
  523. width: 60%;
  524. margin-left: 40%;
  525. background: #fff;
  526. margin-bottom: 20rpx;
  527. display: flex;
  528. flex-direction: row;
  529. align-items: center;
  530. padding-left: 30rpx;
  531. padding-right: 30rpx;
  532. }
  533. .fb-type .type-label {
  534. height: 36rpx;
  535. flex: 1;
  536. color: #333;
  537. font-size: 28rpx;
  538. }
  539. .fb-type .type-icon {
  540. height: 36rpx;
  541. width: 36rpx;
  542. }
  543. .form-item {
  544. display: flex;
  545. align-items: center;
  546. text-align: center;
  547. }
  548. </style>
  549. <style scoped>
  550. .progressContainer {
  551. position: relative;
  552. width: 160rpx;
  553. height: 600rpx;
  554. background-color: #ddd;
  555. overflow: hidden;
  556. margin: 20rpx auto;
  557. }
  558. .progress {
  559. position: absolute;
  560. width: inherit;
  561. bottom: 0;
  562. background-color: #007aff;
  563. }
  564. .progress-view {
  565. width: inherit;
  566. height: inherit;
  567. position: absolute;
  568. top: 0;
  569. }
  570. /deep/ .uni-forms .uni-forms-item__label {
  571. width: 180rpx;
  572. padding: 0;
  573. }
  574. /deep/ .editBox .uni-numbox {
  575. margin-left: 35%;
  576. }
  577. </style>