material.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. <template>
  2. <view class="container">
  3. <uni-section title="原料" type="line" padding>
  4. <uni-grid :column="4" :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="errMsg" v-if="item.exprStatus==='1'">即将到期</text>
  19. <text class="errMsg" v-if="item.mtrResidue <= item.residueWarn">原料不足</text>
  20. <text class="tip">{{item.mtrResidue || '0'}}ml</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}}</uni-td>
  48. <uni-td align="center">{{item.mtrName}}</uni-td>
  49. <uni-td align="center">{{item.specs}}</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">{{material.mtrResidue || '0'}}ml
  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>{{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="replaceMaterial">
  144. <!--<uni-data-select @change="bindPickerChange" v-model="index" collection="equMaterials" field="id as value, mtName as text" v-if="editShow"></uni-data-select>-->
  145. <picker @change="bindPickerChange" v-model="index2" :range="equMaterials" range-key="mtName"
  146. v-if="equMaterials.length>0">
  147. <view class="picker">
  148. <view class="fb-type">
  149. <view class="type-label">{{equMaterials[index2].mtName}}</view>
  150. <image class="type-icon"
  151. src="../../static/images/icon_select.png">
  152. </image>
  153. </view>
  154. </view>
  155. </picker>
  156. </uni-forms-item>
  157. <uni-forms-item class="form-item" label="换料规格" name="specs">
  158. <uni-number-box :min="0" :max="100" v-model="form.specs"></uni-number-box>
  159. </uni-forms-item>
  160. </uni-forms>
  161. <uni-row class="uni-row" style="margin-top: 200rpx">
  162. <uni-col :span="12">
  163. <button @click="update" type="primary" size="mini">确定</button>
  164. </uni-col>
  165. <uni-col :span="12">
  166. <button @click="editClose" type="primary" size="mini">关闭</button>
  167. </uni-col>
  168. </uni-row>
  169. </view>
  170. </uni-popup>
  171. </view>
  172. </view>
  173. </template>
  174. <script>
  175. const util = require("@/utils/util.js");
  176. const api = require('@/utils/api.js');
  177. //import MaterialDetail from "@/pages/material/materialDetail.vue";
  178. export default {
  179. data() {
  180. return {
  181. index: 0,
  182. index2: 0,
  183. array: [1, 2, 3, 4, 5, 6, 7, 8, 9],
  184. specs: [5, 10, 20],
  185. popShow: false,
  186. editShow: false,
  187. materials: ['燕麦', '魔芋粉', '牛肉粉', '红薯粉', '蜂蜜'],
  188. material: {
  189. equId: '',
  190. barrelCode: '',
  191. mtrName: '',
  192. surplus: '',
  193. specs: '',
  194. date: '',
  195. status: ''
  196. },
  197. form: {
  198. materialId: '',
  199. equId: '',
  200. barrelCode: '',
  201. currentMaterial: '',
  202. mtName: '',
  203. replaceMaterial: '',
  204. surplus: '',
  205. specs: '',
  206. date: ''
  207. },
  208. records: [{
  209. id: 1,
  210. name: '燕麦',
  211. rawMaterial: '燕麦',
  212. surplus: '2',
  213. specs: '10',
  214. date: '2021-11-14 12:13'
  215. }],
  216. records2: [{
  217. id: 1,
  218. name: '燕麦',
  219. surplus: '2',
  220. specs: '10',
  221. date: '2021-11-14 12:13',
  222. status: 0,
  223. }, {
  224. id: 2,
  225. name: '燕麦',
  226. surplus: '2',
  227. specs: '10',
  228. date: '2021-11-14 12:13',
  229. status: 1,
  230. }],
  231. rangeIds: [{
  232. value: 1,
  233. text: "1"
  234. },
  235. {
  236. value: 2,
  237. text: "2"
  238. },
  239. {
  240. value: 3,
  241. text: "3"
  242. }
  243. ],
  244. equMaterials: [],
  245. allEquMaterials: [],
  246. queryParams: util.initQueryParams(),
  247. totalPages: 1,
  248. rangeSurplus: [{
  249. value: 1,
  250. text: "5"
  251. },
  252. {
  253. value: 2,
  254. text: "10"
  255. },
  256. {
  257. value: 3,
  258. text: "20"
  259. }
  260. ],
  261. rangeSpecs: [{
  262. value: 1,
  263. text: "5"
  264. },
  265. {
  266. value: 2,
  267. text: "10"
  268. },
  269. {
  270. value: 3,
  271. text: "20"
  272. }
  273. ],
  274. rangeDates: [{
  275. value: "2021-11-14",
  276. text: "2021-11-14"
  277. },
  278. {
  279. value: "2021-12-24",
  280. text: "2021-12-24"
  281. },
  282. {
  283. value: "2022-08-01",
  284. text: "2022-08-01"
  285. }
  286. ],
  287. categoryList: [{
  288. id: 1,
  289. barrleCode: 1,
  290. mtrName: "燕麦",
  291. mtrResidue: 40,
  292. status: 1,
  293. exprStatus: '0',
  294. errMsg: '原料不足',
  295. }, {
  296. id: 2,
  297. barrleCode: 2,
  298. mtrName: "魔芋粉",
  299. mtrResidue: 60,
  300. status: 1,
  301. exprStatus: '0',
  302. errMsg: '即将过期',
  303. }, {
  304. id: 3,
  305. barrleCode: 3,
  306. mtrName: "红薯粉",
  307. mtrResidue: 80,
  308. exprStatus: '1',
  309. status: 0,
  310. errMsg: '',
  311. }, {
  312. id: 4,
  313. barrleCode: 4,
  314. mtrName: "牛肉粉",
  315. mtrResidue: 65,
  316. exprStatus: '0',
  317. status: 0,
  318. errMsg: '',
  319. }, {
  320. id: 5,
  321. barrleCode: 5,
  322. mtrName: "蜂蜜",
  323. mtrResidue: 40,
  324. exprStatus: '1',
  325. status: 0,
  326. errMsg: '',
  327. }, {
  328. id: 6,
  329. barrleCode: 6,
  330. mtrName: "安赛蜜",
  331. mtrResidue: 60,
  332. status: 0,
  333. exprStatus: '0',
  334. errMsg: '',
  335. }, {
  336. id: 7,
  337. barrleCode: 7,
  338. mtrName: "牛奶",
  339. mtrResidue: 80,
  340. status: 0,
  341. exprStatus: '1',
  342. errMsg: '',
  343. }, {
  344. id: 8,
  345. barrleCode: 8,
  346. mtrName: "橙汁",
  347. mtrResidue: 65,
  348. exprStatus: '0',
  349. status: 0,
  350. errMsg: '',
  351. }],
  352. }
  353. },
  354. components: {
  355. //MaterialDetail
  356. },
  357. methods: {
  358. inputDialogToggle(row) {
  359. //if (row.mtrResidue) {
  360. this.popShow = true
  361. this.$refs.inputDialog.open()
  362. //this.$refs.detail.setMaterial(row);
  363. this.material = row;
  364. //}
  365. },
  366. dialogClose() {
  367. this.popShow = false
  368. this.$refs.inputDialog.close()
  369. },
  370. editDialog(row) {
  371. this.dialogClose()
  372. this.editShow = true
  373. this.form = {
  374. 'barrelType': row.barrelType,
  375. 'materialId': row.id,
  376. 'currentMaterial': row.mtrId,
  377. 'mtName': row.mtrName,
  378. 'surplus': row.mtrResidue,
  379. 'date': row.exprTime,
  380. 'barrelCode': row.barrelCode,
  381. 'equId': row.equId
  382. }
  383. console.log(this.form)
  384. this.$refs.editDialog.open()
  385. //this.$refs.edit.setMaterial(row);
  386. if (row.barrelType == null || row.barrelType == "") {
  387. this.equMaterials = this.allEquMaterials.filter(item => {
  388. return item.mtType != "4" && item.mtType != "5";
  389. });
  390. } else {
  391. this.equMaterials = this.allEquMaterials.filter(item => {
  392. return item.mtType == row.barrelType;
  393. });
  394. }
  395. //console.log(this.form)
  396. },
  397. editClose() {
  398. this.editShow = false
  399. this.equMaterials = this.allEquMaterials
  400. },
  401. getMaterialData(equId) {
  402. let that = this;
  403. util.request(api.MaterialList, {
  404. equId: equId,
  405. barrelType: '',
  406. }, 'GET', 'application/json').then(function(res) {
  407. if (res.code === 0) {
  408. that.categoryList = res.data.records;
  409. }
  410. });
  411. },
  412. getRecordList(equId) {
  413. let that = this;
  414. that.queryParams.model.equId = equId
  415. util.request(api.RecordList, that.queryParams, 'Post', 'application/json').then(function(res) {
  416. if (res.code === 0) {
  417. that.records = that.records.concat(res.data.records)
  418. that.totalPages = res.data.pages
  419. }
  420. });
  421. },
  422. bindPickerChange: function(e) {
  423. this.index2 = e.detail.value
  424. this.form.replaceMaterial = this.equMaterials[this.index2].id
  425. },
  426. getEquMaterialData: function() {
  427. let that = this;
  428. util.request(api.EquMaterialList, {
  429. mtType: ''
  430. }, 'GET', 'application/json').then(function(res) {
  431. if (res.code === 0) {
  432. that.allEquMaterials = res.data;
  433. }
  434. });
  435. },
  436. update() {
  437. let that = this;
  438. let pages = getCurrentPages();
  439. let page = pages[pages.length - 1].$page.fullPath;
  440. let equId = page.split('equId=')[1]
  441. equId = equId? equId: ""
  442. util.request(api.RecordAdd, this.form, "POST", "application/json").then(function(res) {
  443. if (res.code === 0) {
  444. uni.showToast({
  445. title: "操作结果",
  446. icon: 'success',
  447. duration: 1000,
  448. complete: function() {
  449. setTimeout(function() {
  450. that.editClose()
  451. uni.reLaunch({
  452. url: '/pages/material/material?equId='+equId,
  453. });
  454. }, 2000);
  455. }
  456. });
  457. } else {
  458. util.toast(res.data);
  459. }
  460. });
  461. },
  462. onReachBottom: function() {
  463. let pages = getCurrentPages();
  464. let page = pages[pages.length - 1].$page.fullPath;
  465. let equId = page.split('equId=')[1]
  466. equId = equId? equId: ""
  467. if (this.totalPages > this.queryParams.current) {
  468. this.queryParams.current = this.queryParams.current + 1
  469. } else {
  470. return false;
  471. }
  472. this.getRecordList(equId)
  473. },
  474. onLoad: function(option) {
  475. let equId = option.equId? option.equId : ""
  476. this.getMaterialData(equId);
  477. this.getEquMaterialData();
  478. this.getRecordList(equId);
  479. }
  480. }
  481. }
  482. </script>
  483. <style style="scss">
  484. .grid-item-box .text {
  485. padding: 20rpx 0;
  486. height: 30rpx;
  487. line-height: 30rpx;
  488. font-weight: bold;
  489. width: inherit;
  490. }
  491. .grid-item-box .num {
  492. position: relative;
  493. margin: 0 auto;
  494. z-index: 999;
  495. }
  496. .grid-item-box .tip {
  497. position: absolute;
  498. bottom: 20rpx;
  499. left: 30%;
  500. margin: 0 auto;
  501. color: #fff;
  502. z-index: 999;
  503. text-align: center;
  504. }
  505. .grid-item-box .errMsg {
  506. position: absolute;
  507. left: 30%;
  508. top: 120rpx;
  509. font-size: 36rpx;
  510. width: 80rpx;
  511. color: #ff0000;
  512. z-index: 9999;
  513. margin: 0 auto;
  514. }
  515. .fb-type {
  516. height: 104rpx;
  517. width: 75%;
  518. margin-left: 20%;
  519. background: #fff;
  520. margin-bottom: 20rpx;
  521. display: flex;
  522. flex-direction: row;
  523. align-items: center;
  524. padding-left: 30rpx;
  525. padding-right: 30rpx;
  526. }
  527. .fb-type .type-label {
  528. height: 36rpx;
  529. flex: 1;
  530. color: #333;
  531. font-size: 28rpx;
  532. }
  533. .fb-type .type-icon {
  534. height: 36rpx;
  535. width: 36rpx;
  536. }
  537. .popup-content {
  538. align-items: center;
  539. justify-content: center;
  540. padding: 15px;
  541. height: 50px;
  542. background-color: #fff;
  543. }
  544. .popup {
  545. display: block;
  546. padding: 5rpx 10rpx 0;
  547. overflow: hidden;
  548. background-color: #fff;
  549. }
  550. .uni-row {
  551. margin-bottom: 10px;
  552. display: block;
  553. }
  554. .uni-col {
  555. height: 36px;
  556. border-radius: 5px;
  557. text-align: center;
  558. }
  559. .fb-type {
  560. height: 84rpx;
  561. width: 60%;
  562. margin-left: 40%;
  563. background: #fff;
  564. margin-bottom: 20rpx;
  565. display: flex;
  566. flex-direction: row;
  567. align-items: center;
  568. padding-left: 30rpx;
  569. padding-right: 30rpx;
  570. }
  571. .fb-type .type-label {
  572. height: 36rpx;
  573. flex: 1;
  574. color: #333;
  575. font-size: 28rpx;
  576. }
  577. .fb-type .type-icon {
  578. height: 36rpx;
  579. width: 36rpx;
  580. }
  581. .form-item {
  582. display: flex;
  583. align-items: center;
  584. text-align: center;
  585. }
  586. </style>
  587. <style scoped>
  588. .progressContainer {
  589. position: relative;
  590. width: 160rpx;
  591. height: 600rpx;
  592. background-color: #ddd;
  593. overflow: hidden;
  594. margin: 20rpx auto;
  595. }
  596. .progress {
  597. position: absolute;
  598. width: inherit;
  599. bottom: 0;
  600. background-color: #007aff;
  601. }
  602. .progress-view {
  603. width: inherit;
  604. height: inherit;
  605. position: absolute;
  606. top: 0;
  607. }
  608. /deep/ .uni-forms .uni-forms-item__label {
  609. width: 180rpx;
  610. padding: 0;
  611. }
  612. /deep/ .uni-forms .uni-forms-item__content {
  613. padding: 0;
  614. height: 36px;
  615. line-height: 36px;
  616. vertical-align: middle;
  617. }
  618. /deep/ .uni-popup .uni-popup__wrapper .popup {
  619. min-width: 600rpx;
  620. }
  621. /deep/ .editBox .uni-popup .uni-popup__wrapper .popup {
  622. min-height: 1000rpx;
  623. }
  624. /deep/ .editBox .uni-numbox {
  625. margin-left: 35%;
  626. }
  627. </style>