add feeding record

main
chenshuichuan 2 years ago
parent c40fe153e1
commit d8ffff6bd9

@ -0,0 +1,18 @@
import request from '@/utils/request'
// 单位列表
export function getUnitList() {
return request({
url: '/admin-api/mes/app/product/getUnitList',
method: 'get'
})
}
// 原料列表
export function getItemList() {
return request({
url: '/admin-api/mes/app/product/getItemList',
method: 'get'
})
}

@ -27,7 +27,7 @@ export function create(data) {
return request({
url: '/admin-api/mes/feeding-record/create',
method: 'post',
params: data
data: data
})
}
// 更新

@ -1,7 +1,7 @@
// 应用全局配置
const config = {
// baseUrl: 'http://47.106.185.127:48080',127.0.0.1
baseUrl: 'http://127.0.0.1:48080',
baseUrl: 'http://47.106.185.127:48080',
// 应用信息
appInfo: {
// 应用名称

@ -0,0 +1,188 @@
<template>
<view class="container">
<view class="example">
<uni-forms ref="customForm" :rules="customRules" labelWidth="60px" :modelValue="formData">
<uni-forms-item label="制浆线" required name="feedingPipeline">
<uni-data-checkbox v-model="formData.feedingPipeline" :localdata="pipelineTypes()" />
</uni-forms-item>
<uni-forms-item label="投料类型" required name="feedingType">
<uni-data-checkbox v-model="formData.feedingType" :localdata="feedingTypes()" @change="handleTypeChange"/>
</uni-forms-item>
<uni-forms-item v-if="formData.feedingType==='wet' || formData.feedingType==='dry'" label="重量/kg" name="weight">
<uni-easyinput type="number" v-model="formData.weight" placeholder="" />
</uni-forms-item>
<uni-forms-item label="备注" name="remark">
<uni-easyinput v-model="formData.remark" placeholder="" />
</uni-forms-item>
<uni-group title="card 模式" mode="card" v-for="(item,index) in formData.productList" :key="item.id"
:name="['productList',index,'value']">
<template v-slot:title>
<view class="uni-group-title">
<uni-row>
<uni-col :span="18">
<uni-forms-item label="原料" required name="itemId">
<uni-data-select placement="top" v-model="formData.productList[index].itemId" :localdata="itemList"></uni-data-select>
</uni-forms-item>
</uni-col>
<uni-col :span="6" align="center">
<uni-icons type="trash" size="25" color="red" @click="del(item.id)"></uni-icons>
</uni-col>
</uni-row>
</view>
</template>
<uni-forms-item label="单位" required name="unitId">
<uni-data-select v-model="formData.productList[index].unitId" :localdata="unitList"></uni-data-select>
</uni-forms-item>
<uni-forms-item label="数量" required name="weight">
<uni-easyinput type="number" v-model="formData.productList[index].weight"/>
</uni-forms-item>
</uni-group>
</uni-forms>
<view class="button-group">
<button v-if="formData.feedingType==='org'" type="primary" size="mini" @click="add">
<uni-icons type="plus" size="15"></uni-icons>
添加原料
</button>
<button type="primary" size="mini" @click="submit('customForm')"></button>
</view>
</view>
</view>
</template>
<script>
import {create} from "@/api/mes/record"
import {getUnitList,getItemList} from "@/api/mes/product"
import { pipelineTypes,feedingTypes, findTextByValue} from "@/api/system/dict/data";
import {showConfirm} from "@/utils/common";
import tab from "@/plugins/tab";
import modal from "@/plugins/modal";
export default {
components: {},
data() {
return {
//
formData: {
id: undefined,
feedingPipeline: undefined,
feedingType: undefined,
weight: undefined,
remark: undefined,
productList: []
},
//
customRules: {
feedingPipeline: {rules: [{required: true, errorMessage: '姓名不能为空'}]},
feedingType: {rules: [{required: true, errorMessage: '工位不能为空'}]},
productList: {rules: [
{format: 'array', errorMessage: '产品列表格式错误'},
{validateFunction: function(rule, value, data, callback) {
if (value.length < 2) {
callback('产品信息不能为空')
}
return true
}
}]
}
},
itemList:[],
unitList:[]
}
},
computed: {
},
onLoad() {
this.getItemList()
},
onReady() {
//
this.$refs.customForm.setRules(this.customRules)
},
methods: {
pipelineTypes() {return pipelineTypes},
feedingTypes() {return feedingTypes},
submit(ref) {
this.$refs[ref].validate().then(res => {
var ok = 1;
if(this.formData.productList && this.formData.productList.length > 0) {
for (let i = 0; i < this.formData.productList.length; i++) {
if(!this.formData.productList[i].itemId || this.formData.productList[i].itemId===''
|| !this.formData.productList[i].weight|| this.formData.productList[i].weight <= 0) {
ok = 0;
uni.showToast({
title: `原料信息不能为空!`,
icon: 'error'
})
break;
}
}
}
if(ok===1){
showConfirm("确认保存投料记录单吗?").then(res => {
if (res.confirm) {
create(this.formData).then(response => {
modal.msgSuccess("保存成功")
tab.navigateBack()
})
}
})
}
}).catch(err => {
console.log('err', err);
})
},
handleTypeChange(e){
this.formData.feedingType =e.detail.value;
if(this.formData.feedingType === 'wet' || this.formData.feedingType==='dry'){
this.formData.productList = []
}
},
getItemList() {
getItemList().then(response => {
this.itemList = response.data;
})
getUnitList().then(response => {
this.unitList = response.data;
})
},
add() {
this.formData.productList.push({
id: Date.now(),
itemId: undefined,
unitId: 3,
weight: 0
})
},
del(id) {
let index = this.formData.productList.findIndex(v => v.id === id)
this.formData.productList.splice(index, 1)
}
}
}
</script>
<style lang="scss">
.example {
padding: 15px;
background-color: #fff;
}
.button-group {
margin-top: 15px;
display: flex;
justify-content: space-around;
}
.button {
display: flex;
align-items: center;
height: 35px;
line-height: 35px;
margin-left: 10px;
}
.uni-group-title{
padding-top: 5px;
background-color: #f4c7c7;
}
</style>

@ -1,336 +0,0 @@
<template>
<view class="container">
<uni-card :is-shadow="false" is-full>
<text class="uni-h6">uni-forms 组件一般由输入框选择器单选框多选框等控件组成用以收集校验提交数据</text>
</uni-card>
<uni-section title="基本用法" type="line">
<view class="example">
<!-- 基础用法不包含校验规则 -->
<uni-forms ref="baseForm" :model="baseFormData" labelWidth="80px">
<uni-forms-item label="姓名" required>
<uni-easyinput v-model="baseFormData.name" placeholder="请输入姓名" />
</uni-forms-item>
<uni-forms-item label="年龄" required>
<uni-easyinput v-model="baseFormData.age" placeholder="请输入年龄" />
</uni-forms-item>
<uni-forms-item label="性别" required>
<uni-data-checkbox v-model="baseFormData.sex" :localdata="sexs" />
</uni-forms-item>
<uni-forms-item label="兴趣爱好" required>
<uni-data-checkbox v-model="baseFormData.hobby" multiple :localdata="hobbys" />
</uni-forms-item>
<uni-forms-item label="自我介绍">
<uni-easyinput type="textarea" v-model="baseFormData.introduction" placeholder="请输入自我介绍" />
</uni-forms-item>
<uni-forms-item label="日期时间">
<uni-datetime-picker type="datetime" return-type="timestamp"
v-model="baseFormData.datetimesingle" />
</uni-forms-item>
<uni-forms-item label="选择城市">
<uni-data-picker v-model="baseFormData.city" :localdata="cityData" popup-title="选择城市">
</uni-data-picker>
</uni-forms-item>
<uni-forms-item label="选择技能">
<uni-data-select v-model="baseFormData.skills" :localdata="skillsRange" >
</uni-data-select>
</uni-forms-item>
</uni-forms>
</view>
</uni-section>
<uni-section title="表单校验" type="line">
<view class="example">
<!-- 基础表单校验 -->
<uni-forms ref="valiForm" :rules="rules" :model="valiFormData" labelWidth="80px">
<uni-forms-item label="姓名" required name="name">
<uni-easyinput v-model="valiFormData.name" placeholder="请输入姓名" />
</uni-forms-item>
<uni-forms-item label="年龄" required name="age">
<uni-easyinput v-model="valiFormData.age" placeholder="请输入年龄" />
</uni-forms-item>
<uni-forms-item label="自我介绍">
<uni-easyinput type="textarea" v-model="valiFormData.introduction" placeholder="请输入自我介绍" />
</uni-forms-item>
</uni-forms>
<button type="primary" @click="submit('valiForm')"></button>
</view>
</uni-section>
<uni-section title="自定义校验规则" type="line">
<view class="example">
<!-- 自定义表单校验 -->
<uni-forms ref="customForm" :rules="customRules" labelWidth="80px" :modelValue="customFormData">
<uni-forms-item label="姓名" required name="name">
<uni-easyinput v-model="customFormData.name" placeholder="请输入姓名" />
</uni-forms-item>
<uni-forms-item label="年龄" required name="age">
<uni-easyinput v-model="customFormData.age" placeholder="请输入年龄" />
</uni-forms-item>
<uni-forms-item label="兴趣爱好" required name="hobby">
<uni-data-checkbox v-model="customFormData.hobby" multiple :localdata="hobbys" />
</uni-forms-item>
</uni-forms>
<button type="primary" @click="submit('customForm')"></button>
</view>
</uni-section>
<uni-section title="动态表单" type="line">
<view class="example">
<!-- 动态表单校验 -->
<uni-forms ref="dynamicForm" :rules="dynamicRules" :model="dynamicFormData" labelWidth="80px">
<uni-forms-item label="邮箱" required name="email">
<uni-easyinput v-model="dynamicFormData.email" placeholder="请输入姓名" />
</uni-forms-item>
<uni-forms-item v-for="(item,index) in dynamicFormData.domains" :key="item.id"
:label="item.label+' '+index" required :rules="item.rules" :name="['domains',index,'value']">
<view class="form-item">
<uni-easyinput v-model="dynamicFormData.domains[index].value" placeholder="请输入域名" />
<button class="button" size="mini" type="default" @click="del(item.id)"></button>
</view>
</uni-forms-item>
</uni-forms>
<view class="button-group">
<button type="primary" size="mini" @click="add"></button>
<button type="primary" size="mini" @click="submit('dynamicForm')"></button>
</view>
</view>
</uni-section>
</view>
</template>
<script>
export default {
data() {
return {
//
baseFormData: {
name: '',
age: '',
introduction: '',
sex: 2,
hobby: [5],
datetimesingle: 1627529992399,
city: '',
skills: 0
},
//
cityData: [{
text: "北京",
value: "10001",
}, {
text: "上海",
value: "10002",
}, {
text: "深圳",
value: "10004",
}],
skillsRange: [{
value: 0,
text: "编程"
},
{
value: 1,
text: "绘画"
},
{
value: 2,
text: "运动"
},
],
//
alignmentFormData: {
name: '',
age: '',
},
//
sexs: [{
text: '男',
value: 0
}, {
text: '女',
value: 1
}, {
text: '保密',
value: 2
}],
//
hobbys: [{
text: '跑步',
value: 0
}, {
text: '游泳',
value: 1
}, {
text: '绘画',
value: 2
}, {
text: '足球',
value: 3
}, {
text: '篮球',
value: 4
}, {
text: '其他',
value: 5
}],
//
current: 0,
items: ['左对齐', '顶部对齐'],
//
valiFormData: {
name: '',
age: '',
introduction: '',
},
//
rules: {
name: {
rules: [{
required: true,
errorMessage: '姓名不能为空'
}]
},
age: {
rules: [{
required: true,
errorMessage: '年龄不能为空'
}, {
format: 'number',
errorMessage: '年龄只能输入数字'
}]
}
},
//
customFormData: {
name: '',
age: '',
hobby: []
},
//
customRules: {
name: {
rules: [{
required: true,
errorMessage: '姓名不能为空'
}]
},
age: {
rules: [{
required: true,
errorMessage: '年龄不能为空'
}]
},
hobby: {
rules: [{
format: 'array'
},
{
validateFunction: function(rule, value, data, callback) {
if (value.length < 2) {
callback('请至少勾选两个兴趣爱好')
}
return true
}
}
]
}
},
dynamicFormData: {
email: '',
domains: []
},
dynamicLists: [],
dynamicRules: {
email: {
rules: [{
required: true,
errorMessage: '域名不能为空'
}, {
format: 'email',
errorMessage: '域名格式错误'
}]
}
}
}
},
computed: {
//
alignment() {
if (this.current === 0) return 'left'
if (this.current === 1) return 'top'
return 'left'
}
},
onLoad() {},
onReady() {
//
this.$refs.customForm.setRules(this.customRules)
},
methods: {
onClickItem(e) {
console.log(e);
this.current = e.currentIndex
},
add() {
this.dynamicFormData.domains.push({
label: '域名',
value: '',
rules: [{
'required': true,
errorMessage: '域名项必填'
}],
id: Date.now()
})
},
del(id) {
let index = this.dynamicLists.findIndex(v => v.id === id)
this.dynamicLists.splice(index, 1)
},
submit(ref) {
console.log(this.baseFormData);
this.$refs[ref].validate().then(res => {
console.log('success', res);
uni.showToast({
title: `校验通过`
})
}).catch(err => {
console.log('err', err);
})
},
}
}
</script>
<style lang="scss">
.example {
padding: 15px;
background-color: #fff;
}
.segmented-control {
margin-bottom: 15px;
}
.button-group {
margin-top: 15px;
display: flex;
justify-content: space-around;
}
.form-item {
display: flex;
align-items: center;
flex: 1;
}
.button {
display: flex;
align-items: center;
height: 35px;
line-height: 35px;
margin-left: 10px;
}
</style>

@ -84,6 +84,17 @@
}
]
},
{
"root": "page_record",
"pages": [
{
"path": "feedingRecordForm",
"style": {
"navigationBarTitleText": "新增投料记录"
}
}
]
},
{
"root": "pages_mine/pages",
"pages": [

@ -177,6 +177,12 @@ export default {
this.getUserList()
this.loading = false
},
onPullDownRefresh() {
console.log('refresh');
setTimeout(function () {
uni.stopPullDownRefresh();
}, 1000);
},
methods: {
processTypes() {
return processTypes
@ -201,6 +207,7 @@ export default {
timestampToTime,
getOtherReportList(){
let date = this.valiFormData.reportDateString
if(date.length<5)date = getCurrentDate()
this.valiFormData.reportDate = [date+' 00:00:00', date+' 23:59:59']
this.valiFormData.reportType = '个人'
getOtherList(this.valiFormData).then(response => {
@ -209,6 +216,7 @@ export default {
},
getReplaceReportList(){
let date = this.valiFormData.reportDateString
if(date.length<5)date = getCurrentDate()
this.valiFormData.reportDate = [date+' 00:00:00', date+' 23:59:59']
this.valiFormData.reportType = '代报工'
getOtherList(this.valiFormData).then(response => {

@ -76,6 +76,7 @@
</el-row>
</el-collapse-item>
</el-collapse>
<uni-fab ref="fab" :pattern="pattern" @fabClick="handleAdd" />
</view>
</template>
@ -88,13 +89,19 @@ import {Tickets} from "@element-plus/icons-vue";
import modal from "@/plugins/modal";
import tab from "@/plugins/tab";
import {showConfirm} from "@/utils/common";
import auth from "@/plugins/auth";
//
const finishList = ref([]);
//稿
const draftList = ref([]);
const pattern = {
color: '#7A7E83',
backgroundColor: '#fff',
selectedColor: '#007AFF',
buttonColor: '#f4c7c7',
iconColor: '#fff'
}
onMounted(() => {
getList()
@ -141,9 +148,9 @@ function handleDelete(id){
})
}
//
function planProgress(plan){
tab.navigateTo('/page_report/planProgress',plan)
//
function handleAdd(){
tab.navigateTo('/page_record/feedingRecordForm')
}
</script>

Loading…
Cancel
Save