material.vue 16 KB

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