This commit is contained in:
shilixia 2021-09-29 09:57:33 +08:00
parent 611736c4c6
commit c36d214573
2 changed files with 350 additions and 252 deletions

View File

@ -61,7 +61,11 @@
width="220px"
>
<template slot-scope="scope">
<el-link
v-if="checkPermission(['warehouse_update'])"
@click="handleMaterial(scope)"
>查看物料</el-link
>
<el-link
v-if="checkPermission(['warehouse_update'])"
@click="handleEdit(scope)"
@ -174,7 +178,9 @@ export default {
});
},
handleMaterial(scope){
alert(1)
},
handleFilter() {
this.listQuery.page = 1;
this.getList();

View File

@ -1,216 +1,276 @@
<template>
<div class="app-container">
<el-card>
<el-row :gutter="24">
<el-col :span="6" >
<el-card >
<div slot="header" class="clearfix">
<span style="font-size: 16px;
font-weight: 700;
">过程记录表</span>
</div>
<el-button type="primary" icon="el-icon-plus" @click="handleCreate"
>新增</el-button>
<el-table
:data="recordformList.results"
border
fit
stripe
highlight-current-row
height="100"
v-el-height-adaptive-table="{bottomOffset: 50}"
@current-change="handleCurrentChange"
>
<el-table-column type="index" width="50" />
<el-table-column label="表名称">
<template slot-scope="scope">{{ scope.row.name }}</template>
</el-table-column>
<el-table-column
align="center"
label="操作"
>
<template slot-scope="scope">
<el-link
v-if="checkPermission(['material_update'])"
@click="handleLook(scope)"
>查看</el-link>
<el-link
v-if="checkPermission(['material_update'])"
@click="handleEdit(scope)"
>编辑</el-link>
<el-link
v-if="checkPermission(['material_delete'])"
type="danger"
@click="handleDelete(scope)"
>删除</el-link>
</template>
</el-table-column>
</el-table>
<el-dialog
:visible.sync="dialogVisible"
:title="dialogType === 'edit' ? '编辑记录表格' : '新增记录表格'"
>
<el-form
ref="Forms"
:model="recordform"
label-width="80px"
label-position="right"
>
<el-tabs type="border-card">
<el-tab-pane label="过程记录">
<el-row :gutter="24">
<el-col :span="6" >
<el-card style="margin-top: 10px">
<el-button type="primary" icon="el-icon-plus" @click="handleCreate"
>新增</el-button>
<el-table
:data="recordformList.results"
border
fit
stripe
highlight-current-row
height="100"
v-el-height-adaptive-table="{bottomOffset: 50}"
@current-change="handleCurrentChange"
>
<el-table-column type="index" width="50" />
<el-table-column label="表名称">
<template slot-scope="scope">{{ scope.row.name }}</template>
<el-form-item label="表格名称" prop="name">
<el-input v-model="recordform.name" placeholder="表格名称" />
</el-form-item>
<el-form-item label="表格类型" prop="type">
<el-select style="width: 100%" v-model="recordform.type" placeholder="请选择">
<el-option
v-for="item in typeoptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-table-column>
<el-table-column
align="center"
label="操作"
</el-form>
<div style="text-align: right">
<el-button type="danger" @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="recordformconfirm('Forms')">确认</el-button>
</div>
</el-dialog>
<el-dialog
:model="tableForm"
:visible.sync="dialogVisibleForm"
:title="tableForm.name">
<el-form
label-width="80px"
label-position="right"
>
<el-row v-for="(item,$index) in fieldList.results" :key="$index">
<el-form-item v-if="item.field_type==='string'" :label="item.field_name" >
<el-input placeholder="请输入" v-model="item.sort"/>
</el-form-item>
<el-form-item v-else-if="item.field_type==='int'" :label="item.field_name">
<el-input type="number" placeholder="请输入" v-model="item.sort"/>
</el-form-item>
<el-form-item v-else-if="item.field_type==='float'" :label="item.field_name">
<el-input type="number" placeholder="请输入" v-model="item.sort"/>
</el-form-item>
<el-form-item v-else-if="item.field_type==='date'" :label="item.field_name">
<el-date-picker
v-model="item.create_time"
type="date"
placeholder="选择日期"
value-format="yyyy-MM-dd"
style="width:100%"
>
</el-date-picker>
</el-form-item>
<el-form-item v-else-if="item.field_type==='datetime'" :label="item.field_name">
<el-date-picker
v-model="item.create_time"
type="datetime"
placeholder="选择日期"
value-format="yyyy-MM-dd HH:mm:ss"
style="width:100%"
>
</el-date-picker>
</el-form-item>
<el-form-item v-else-if="item.field_type==='select'" :label="item.field_name">
<el-select style="width: 100%" v-model="item.sort" placeholder="请选择">
<el-option
v-for="item1 in item.field_choice"
:key="item1"
:label="item1"
:value="item1">
</el-option>
</el-select>
</el-form-item>
<el-form-item v-else-if="item.field_type==='selects'" :label="item.field_name">
<el-select style="width: 100%" v-model="optio" multiple placeholder="请选择">
<el-option
v-for="item1 in item.field_choice"
:key="item1"
:label="item1"
:value="item1">
</el-option>
</el-select>
</el-form-item>
</el-row>
</el-form>
<!--<div style="text-align: right">-->
<!--<el-button type="danger">取消</el-button>-->
<!--<el-button type="primary">确认</el-button>-->
<!--</div>-->
</el-dialog>
</el-card>
</el-col>
<el-col :span="18" >
<el-card >
<div slot="header" class="clearfix">
<span style="font-size: 16px;
font-weight: 700;
">记录字段</span>
</div>
<el-button type="primary" icon="el-icon-plus" @click="handlefieldCreate"
>新增</el-button>
<el-table
:data="fieldList.results"
border
fit
stripe
highlight-current-row
height="100"
v-el-height-adaptive-table="{bottomOffset: 50}"
>
<el-table-column type="index" width="50" />
<el-table-column label="字段类型">
<template slot-scope="scope">{{ options_[scope.row.field_type] }}</template>
</el-table-column>
<el-table-column label="字段名称">
<template slot-scope="scope">{{ scope.row.field_name }}</template>
</el-table-column>
<el-table-column label="字段标识">
<template slot-scope="scope">{{ scope.row.field_key }}</template>
</el-table-column>
<el-table-column label="选项显示名">
<template slot-scope="scope">{{ scope.row.field_choice }}</template>
</el-table-column>
<el-table-column
align="center"
label="操作"
>
<template slot-scope="scope">
<el-link
v-if="checkPermission(['material_update'])"
@click="handlefieldEdit(scope)"
>编辑</el-link
>
<template slot-scope="scope">
<el-link
v-if="checkPermission(['material_update'])"
@click="handleEdit(scope)"
>编辑</el-link
>
<el-link
v-if="checkPermission(['material_delete'])"
type="danger"
@click="handleDelete(scope)"
>删除</el-link
>
</template>
</el-table-column>
</el-table>
<el-dialog
:visible.sync="dialogVisible"
:title="dialogType === 'edit' ? '编辑记录表格' : '新增记录表格'"
>
<el-form
ref="Forms"
:model="recordform"
label-width="80px"
label-position="right"
<el-link
v-if="checkPermission(['material_delete'])"
type="danger"
@click="handlefieldDelete(scope)"
>删除</el-link
>
</template>
</el-table-column>
<el-form-item label="表格名称" prop="name">
<el-input v-model="recordform.name" placeholder="表格名称" />
</el-form-item>
</el-form>
<div style="text-align: right">
<el-button type="danger" @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="recordformconfirm('Forms')">确认</el-button>
</div>
</el-dialog>
</el-card>
</el-col>
<el-col :span="18" >
<el-card class="box-card">
<el-button type="primary" icon="el-icon-plus" @click="handlefieldCreate"
>新增</el-button>
<el-table
:data="fieldList.results"
border
fit
stripe
highlight-current-row
height="100"
v-el-height-adaptive-table="{bottomOffset: 50}"
>
<el-table-column type="index" width="50" />
<el-table-column label="字段类型">
<template slot-scope="scope">{{ options_[scope.row.field_type] }}</template>
</el-table-column>
<el-table-column label="字段名称">
<template slot-scope="scope">{{ scope.row.field_name }}</template>
</el-table-column>
<el-table-column label="字段标识">
<template slot-scope="scope">{{ scope.row.field_key }}</template>
</el-table-column>
<el-table-column label="布尔类型显示名">
<template slot-scope="scope">{{ scope.row.boolean_field_display }}</template>
</el-table-column>
<el-table-column label="选项显示名">
<template slot-scope="scope">{{ scope.row.field_choice }}</template>
</el-table-column>
<el-table-column
align="center"
label="操作"
>
<template slot-scope="scope">
<el-link
v-if="checkPermission(['material_update'])"
@click="handlefieldEdit(scope)"
>编辑</el-link
>
<el-link
v-if="checkPermission(['material_delete'])"
type="danger"
@click="handlefieldDelete(scope)"
>删除</el-link
>
</template>
</el-table-column>
</el-table>
<el-dialog
:visible.sync="dialogVisible1"
:title="dialogType1 === 'edit' ? '编辑表格字段' : '新增表格字段'"
>
<el-form
ref="Form"
:model="field"
label-width="80px"
label-position="right"
>
<el-form-item label="字段类型" prop="field_type">
<el-select style="width: 100%" v-model="field.field_type" placeholder="请选择">
<el-option
v-for="item in fieldtypeoptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="字段标识" prop="field_key">
<el-input v-model="field.field_key" placeholder="字段标识" />
</el-form-item>
<el-form-item label="字段名称" prop="field_name">
<el-input v-model="field.field_name" placeholder="字段名称" />
</el-form-item>
<el-form-item label="布尔类型显示名" prop="boolean_field_display">
<vue-json-editor
v-model="field.boolean_field_display"
:showBtns="false"
:mode="'code'"
lang="zh"
/>
</el-form-item>
<el-form-item label="选项" prop="field_choice">
<vue-json-editor
v-model="field.field_choice"
:showBtns="false"
:mode="'code'"
lang="zh"
/>
</el-form-item>
<el-form-item label="排序" prop="sort">
<el-input v-model="field.sort" placeholder="排序" />
</el-form-item>
</el-form>
<div style="text-align: right">
<el-button type="danger" @click="dialogVisible1 = false">取消</el-button>
<el-button type="primary" @click="fieldconfirm('Form')">确认</el-button>
</div>
</el-dialog>
</el-card>
</el-col>
</el-row>
</el-tab-pane>
</el-tabs>
</el-table>
<el-dialog :visible.sync="dialogVisible1" :title="dialogType1 === 'edit' ? '编辑表格字段' : '新增表格字段'">
<el-form ref="Form" :model="field" label-width="80px" label-position="right">
<el-form-item label="字段类型" prop="field_type">
<el-select style="width: 100%" v-model="field.field_type" placeholder="请选择">
<el-option
v-for="item in fieldtypeoptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="字段标识" prop="field_key">
<el-input v-model="field.field_key" placeholder="字段标识" onkeyup="value=value.replace(/[^A-Za-z_\/]/ig,'')"/>
</el-form-item>
<el-form-item label="字段名称" prop="field_name">
<el-input v-model="field.field_name" placeholder="字段名称" />
</el-form-item>
<el-form-item label="选项" v-show="field.field_type=='radio'||field.field_type=='checkbox'||field.field_type=='select'||field.field_type=='selects'">
<el-button @click.prevent="addDomain" style="border: none;">
<i class="el-icon-circle-plus-outline"></i>
<span style="font-size:14px;">添加</span>
</el-button>
<el-row v-for="(domain, $index) in field_choice" :key=domain+$index style="margin-bottom: 10px">
<el-col :span="20">
<el-input v-model="field_choice[$index]" auto-complete="off"></el-input>
</el-col>
<el-col :span="3" style="text-align: center" v-if="$index!==0">
<i class="el-icon-remove-outline" @click.prevent="removeDomain($index,'1')" style="color: red;font-size: 16px;"></i>
</el-col>
</el-row>
</el-form-item>
<el-form-item label="排序" prop="sort">
<el-input-number v-model="field.sort" :min="1" placeholder="排序"></el-input-number>
</el-form-item>
</el-form>
<div style="text-align: right">
<el-button type="danger" @click="dialogVisible1 = false">取消</el-button>
<el-button type="primary" @click="fieldconfirm('Form')">确认</el-button>
</div>
</el-dialog>
</el-card>
</el-col>
</el-row>
</el-card>
</div>
</template>
<script>
import { getStep,getrecordformList,createrecordform,updaterecordform,deleterecordform,getrffieldList,createrffield,updaterffield,
deleterffield} from "@/api/mtm";
import vueJsonEditor from 'vue-json-editor'
<script>
import checkPermission from "@/utils/permission";
import { getEquipmentAll } from "@/api/equipment";
import { upUrl, upHeaders } from "@/api/file";
import {getrecordformList,createrecordform,updaterecordform,deleterecordform,getrffieldList,createrffield,updaterffield,
deleterffield} from "@/api/mtm";
import vueJsonEditor from 'vue-json-editor'
import { genTree } from "@/utils";
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
const defaultstep = {
name: "",
number: "",
};
const defaultrecordform = {
};
@ -218,17 +278,40 @@
};
export default {
components: { vueJsonEditor },
components: { Pagination,vueJsonEditor },
data() {
return {
step: defaultstep,
stepList:[],
upHeaders: upHeaders(),
upUrl: upUrl(),
fileList:[],
listLoading: true,
dialogVisibles: false,
dialogVisibleForm: false,
dialogTypes: "new",
field: {
field_type:'',
field_key:'',
field_name:'',
sort:'',
field_choice:[""],
},
field_choice:[''],
options:[],
optio:[],
rule1: {
name: [{ required: true, message: "请输入", trigger: "blur" }],
number: [{ required: true, message: "请输入", trigger: "blur" }],
},
recordform: defaultrecordform,
field: defaultfield,
dialogType: "new",
dialogVisible:false,
dialogType1: "new",
dialogVisible1:false,
tableForm:{
name:'',
},
listQueryrecordform: {
page: 1,
page_size: 20,
@ -244,78 +327,81 @@
page_size: 20,
},
options_: {
'string':'字符串',
'int':'整型',
'float': '浮点',
'boolean':'布尔',
'string':'文本',
'int':'整数',
'float':'小数',
'date': '日期',
'datetime': '日期时间',
'radio': '单选',
'checkbox': '多选',
'select': '单选下拉',
'selects': '多选下拉',
'textarea': '文本域'
'select': '单选',
'selects': '多选',
},
fieldtypeoptions: [{
value: 'string',
label: '字符串'
label: '文本'
},
{
value: 'int',
label: ''
label: ''
},
{
value: 'float',
label: '浮点'
},
{
value: 'boolean',
label: '布尔'
label: '小数'
},
{
value: 'date',
label: '日期'
},
{
value: 'time',
label: '时间'
},
{
value: 'datetime',
label: '日期时间'
},
{
value: 'radio',
value: 'select',
label: '单选'
},
{
value: 'checkbox',
label: '多选'
},
{
value: 'select',
label: '单选下拉'
},
{
value: 'selects',
label: '多选下拉'
},
{
value: 'textarea',
label: '文本域'
}],
label: '多选'
}
],
typeoptions: [{
value: 1,
label: '生产记录'
}],
};
},
computed: {},
watch: {
},
watch: {},
created() {
this.step.process = this.$route.params.id;
this.recordformLists();
this.recordformLists();
this.material = this.$route.params.id;
},
methods: {
//添加字段选项
addDomain() {
this.field_choice.push('')
},
//删除字段选项
removeDomain(index){
this.field_choice.splice(index, 1)
},
handleLook(scope){
debugger;
console.log(scope);
this.dialogVisibleForm = true;
this.tableForm = Object.assign({}, scope.row); // copy obj
this.formID=this.tableForm.id;
this.fieldLists();
},
checkPermission,
handleCurrentChange(row){
this.formID=row.id;
this.fieldLists();
@ -323,9 +409,8 @@
},
recordformLists()
{
this.listQueryrecordform.material = this.material;
console.log(this.materialid)
this.listQueryrecordform.type = 2;
this.listQueryrecordform.step=this.stepid;
this.listQueryrecordform.type=2;
getrecordformList(this.listQueryrecordform).then((response) => {
if (response.data) {
this.recordformList = response.data;
@ -339,10 +424,13 @@
getrffieldList(this.listQueryfield).then((response) => {
if (response.data) {
this.fieldList = response.data;
debugger;
console.log(this.fieldList)
}
});
},
//新增记录表
handleCreate() {
this.recordform = Object.assign({}, defaultrecordform);
this.dialogType = "new";
@ -351,7 +439,10 @@
this.$refs["Forms"].clearValidate();
});
},
//新增字段
handlefieldCreate() {
this.field_choice = [''];
this.field = Object.assign({}, defaultfield);
this.dialogType1 = "new";
this.dialogVisible1 = true;
@ -369,6 +460,7 @@
},
handlefieldEdit(scope) {
this.field = Object.assign({}, scope.row); // copy obj
this.field_choice = this.field.field_choice;
this.dialogType1 = "edit";
this.dialogVisible1 = true;
this.$nextTick(() => {
@ -410,7 +502,7 @@
if (valid) {
const isEdit = this.dialogType === "edit";
if (isEdit) {
this.recordform.material=this.material;
this.recordform.step=this.stepid;
this.recordform.type=2;
updaterecordform(this.recordform.id, this.recordform).then((res) => {
if (res.code >= 200) {
@ -420,8 +512,8 @@
}
});
} else {
this.recordform.material=this.material;
this.recordform.type=2;
this.recordform.step=this.stepid
this.recordform.type=2;
createrecordform(this.recordform).then((res) => {
if (res.code >= 200) {
this.recordformLists()
@ -440,8 +532,8 @@
if (valid) {
const isEdit = this.dialogType1 === "edit";
if (isEdit) {
this.field.form=this.formID
this.field.form=this.formID;
this.field.field_choice = this.field_choice;
updaterffield(this.field.id, this.field).then((res) => {
if (res.code >= 200) {
this.fieldLists()
@ -450,8 +542,8 @@
}
});
} else {
this.field.form=this.formID
this.field.form=this.formID;
this.field.field_choice = this.field_choice;
createrffield(this.field).then((res) => {
if (res.code >= 200) {
this.fieldLists()