123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- <template>
- <view class="container">
- <uni-popup ref="editDialog" type="dialog">
- <view class="popup">
- <uni-card :is-shadow="false" is-full>
- <text class="uni-h6">修正原料</text>
- </uni-card>
- <uni-forms class="form" :modelValue="material">
- <uni-forms-item label="料筒" name="id">
- <uni-data-select v-model="material.id" :localdata="rangeIds"></uni-data-select>
- </uni-forms-item>
- <uni-forms-item label="产品" name="name">
- <uni-data-select v-model="material.name" :localdata="rangeNames"></uni-data-select>
- </uni-forms-item>
- <uni-forms-item label="原料剩余" name="surplus">
- <uni-data-select v-model="material.surplus" :localdata="rangeSurplus"></uni-data-select>
- </uni-forms-item>
- <uni-forms-item label="换料规格" name="specs">
- <uni-data-select v-model="material.specs" :localdata="rangeSpecs"></uni-data-select>
- </uni-forms-item>
- <uni-forms-item label="到期日期" name="date">
- <uni-data-select v-model="material.date" :localdata="rangeDates"></uni-data-select>
- </uni-forms-item>
- </uni-forms>
- <view class="button-group">
- <button @click="update" type="primary" size="mini">确定</button>
- <button @click="close" type="primary" size="mini">关闭</button>
- </view>
- </view>
- </uni-popup>
- </view>
- </template>
- <script>
- const util = require("@/utils/util.js");
- const api = require('@/utils/api.js');
- export default {
- data() {
- return {
- rangeIds: [{
- value: 1,
- text: "1"
- },
- {
- value: 2,
- text: "2"
- },
- {
- value: 3,
- text: "3"
- }
- ],
- rangeNames: [{
- value: "燕麦",
- text: "燕麦"
- },
- {
- value: "魔芋粉",
- text: "魔芋粉"
- },
- {
- value: "红薯粉",
- text: "红薯粉"
- }
- ],
- rangeSurplus: [{
- value: 1,
- text: "5"
- },
- {
- value: 2,
- text: "10"
- },
- {
- value: 3,
- text: "20"
- }
- ],
- rangeSpecs: [{
- value: 1,
- text: "5"
- },
- {
- value: 2,
- text: "10"
- },
- {
- value: 3,
- text: "20"
- }
- ],
- rangeDates: [{
- value: "2021-11-14",
- text: "2021-11-14"
- },
- {
- value: "2021-12-24",
- text: "2021-12-24"
- },
- {
- value: "2022-08-01",
- text: "2022-08-01"
- }
- ],
- material: {
- id: '',
- name: '',
- surplus: '',
- specs: '',
- date: '',
- status: ''
- },
- }
- },
- props: {
- dialogVisible: {
- type: Boolean,
- default: false,
- }
- },
- computed: {
- isVisible: {
- get() {
- return this.dialogVisible
- },
- set() {
- this.close()
- }
- }
- },
- methods: {
- setMaterial(row) {
- if (row) {
- this.material = {
- ...row
- }
- }
- this.$refs.editDialog.open();
- },
- close() {
- this.$refs.editDialog.close();
- },
- update() {
- util.request(api.MaterialUpdate, this.material, "POST", "application/json").then(function(res) {
- if (res.errno === 0) {
- uni.showToast({
- title: res.data,
- icon: 'success',
- duration: 2000,
- complete: function() {
- setTimeout(function() {
- uni.switchTab({
- url: '/pages/material/material',
- });
- }, 2000)
- }
- });
- } else {
- util.toast(res.data);
- }
- });
- }
- },
- }
- </script>
- <style type="scss">
- .form {
- padding: 10px;
- background-color: #fff;
- width: 640rpx;
- }
- .popup {
- display: block;
- overflow: hidden;
- background-color: #fff;
- }
- .button-group {
- margin-bottom: 20rpx;
- display: flex;
- justify-content: space-around;
- }
- </style>
- <style scoped>
- /deep/ .form .uni-forms-item__label {
- min-width: 140rpx;
- height: 60rpx;
- }
- </style>
|