|
|
@@ -0,0 +1,203 @@
|
|
|
+<template>
|
|
|
+ <ele-modal
|
|
|
+ :title="title"
|
|
|
+ :visible.sync="visible"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ @close="handleClose"
|
|
|
+ resizable
|
|
|
+ maxable
|
|
|
+ width="800px"
|
|
|
+ >
|
|
|
+ <div v-loading="loading">
|
|
|
+ <el-form
|
|
|
+ ref="formRef"
|
|
|
+ :model="form"
|
|
|
+ :rules="rules"
|
|
|
+ label-width="120px"
|
|
|
+ :disabled="type == 'view'"
|
|
|
+ >
|
|
|
+ <el-row style="margin-bottom: 20px" :gutter="20">
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="执行方式编码" prop="code">
|
|
|
+ <el-input
|
|
|
+ v-model="form.code"
|
|
|
+ placeholder="系统自动生成"
|
|
|
+ disabled
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="执行方式名称" prop="name">
|
|
|
+ <el-input
|
|
|
+ v-model="form.name"
|
|
|
+ placeholder="请输入执行方式名称"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row style="margin-bottom: 20px" :gutter="20">
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="所属工序" prop="produceTaskName">
|
|
|
+ <el-input
|
|
|
+ v-model="form.produceTaskName"
|
|
|
+ placeholder="请选择工序"
|
|
|
+ readonly
|
|
|
+ @click.native="openProduceTaskDialog"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="状态" prop="enable">
|
|
|
+ <el-switch
|
|
|
+ v-model="form.enable"
|
|
|
+ :active-value="1"
|
|
|
+ :inactive-value="0"
|
|
|
+ active-text="生效"
|
|
|
+ inactive-text="失效"
|
|
|
+ ></el-switch>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <ProduceDialog
|
|
|
+ ref="produceDialogRef"
|
|
|
+ @changeProduct="selectProduceTask"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <template v-slot:footer>
|
|
|
+ <el-button
|
|
|
+ v-if="type != 'view'"
|
|
|
+ type="primary"
|
|
|
+ @click="submit"
|
|
|
+ :loading="butLoading"
|
|
|
+ >保 存</el-button
|
|
|
+ >
|
|
|
+ <el-button @click="handleClose" :loading="butLoading">关 闭</el-button>
|
|
|
+ </template>
|
|
|
+ </ele-modal>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import dictMixins from '@/mixins/dictMixins';
|
|
|
+ import ProduceDialog from './ProduceDialog.vue';
|
|
|
+ import {
|
|
|
+ recordrulesexecutemethodSave,
|
|
|
+ recordrulesexecutemethodUpdate,
|
|
|
+ recordrulesexecutemethodGetById
|
|
|
+ } from '@/api/recordrulesexecutemethod/index';
|
|
|
+ import { load } from '@amap/amap-jsapi-loader';
|
|
|
+
|
|
|
+ export default {
|
|
|
+ mixins: [dictMixins],
|
|
|
+ components: { ProduceDialog },
|
|
|
+ data() {
|
|
|
+ const formBaseData = {
|
|
|
+ id: null,
|
|
|
+ code: '',
|
|
|
+ name: '',
|
|
|
+ createUserName: '',
|
|
|
+ enable: 1,
|
|
|
+ produceTaskId: null,
|
|
|
+ produceTaskName: '',
|
|
|
+ updateUserName: ''
|
|
|
+ };
|
|
|
+
|
|
|
+ return {
|
|
|
+ visible: false,
|
|
|
+ title: '执行方式',
|
|
|
+ formBaseData,
|
|
|
+ form: JSON.parse(JSON.stringify(formBaseData)),
|
|
|
+ rules: {
|
|
|
+ name: [
|
|
|
+ { required: true, message: '请输入执行方式名称', trigger: 'blur' },
|
|
|
+ { required: true, message: '请输入执行方式名称', trigger: 'change' }
|
|
|
+ ],
|
|
|
+ produceTaskName: [
|
|
|
+ { required: true, message: '请选择所属工序', trigger: 'blur' },
|
|
|
+ { required: true, message: '请选择所属工序', trigger: 'change' }
|
|
|
+ ],
|
|
|
+ enable: [
|
|
|
+ { required: true, message: '请选择状态', trigger: 'blur' },
|
|
|
+ { required: true, message: '请选择状态', trigger: 'change' }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ // 工序列表
|
|
|
+ produceTaskList: [],
|
|
|
+ butLoading: false,
|
|
|
+ type: 'add', // add/edit/view
|
|
|
+ loading: false
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 外部调用,打开弹窗
|
|
|
+ open(type, data = {}) {
|
|
|
+ console.log('data', data);
|
|
|
+ this.type = type;
|
|
|
+ if (type === 'add') {
|
|
|
+ this.title = '新增执行方式';
|
|
|
+ this.form.updateUserName = '';
|
|
|
+ this.form.createUserName = this.$store.state.user.info.name;
|
|
|
+ } else if (type === 'edit') {
|
|
|
+ this.title = '修改执行方式';
|
|
|
+ this.form.updateUserName = this.$store.state.user.info.name;
|
|
|
+ this.getDetails(data.id);
|
|
|
+ } else if (type === 'view') {
|
|
|
+ this.title = '执行方式详情';
|
|
|
+ this.getDetails(data.id);
|
|
|
+ }
|
|
|
+ console.log('this.form', this.form);
|
|
|
+ this.visible = true;
|
|
|
+ },
|
|
|
+ async getDetails(id) {
|
|
|
+ this.loading = true;
|
|
|
+ const data = await recordrulesexecutemethodGetById(id);
|
|
|
+ this.$util.assignObject(this.form, data);
|
|
|
+ this.loading = false;
|
|
|
+ },
|
|
|
+ // 关闭时清理表单
|
|
|
+ handleClose() {
|
|
|
+ this.form = JSON.parse(JSON.stringify(this.formBaseData));
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.formRef.clearValidate();
|
|
|
+ this.visible = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 提交
|
|
|
+ submit() {
|
|
|
+ console.log('this.form', this.form);
|
|
|
+ this.$refs.formRef.validate(async (valid) => {
|
|
|
+ console.log('valid', valid, this.type);
|
|
|
+ if (valid) {
|
|
|
+ this.butLoading = true;
|
|
|
+ if (this.type === 'add') {
|
|
|
+ await recordrulesexecutemethodSave(this.form);
|
|
|
+ this.$message.success('新增成功');
|
|
|
+ } else if (this.type === 'edit') {
|
|
|
+ await recordrulesexecutemethodUpdate(this.form);
|
|
|
+ this.$message.success('修改成功');
|
|
|
+ }
|
|
|
+ this.butLoading = false;
|
|
|
+ this.$emit('refreshTable');
|
|
|
+ this.handleClose();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 选择工序
|
|
|
+ openProduceTaskDialog() {
|
|
|
+ this.$refs.produceDialogRef.open({
|
|
|
+ id: this.form.produceTaskId,
|
|
|
+ name: this.form.produceTaskName
|
|
|
+ });
|
|
|
+ },
|
|
|
+ selectProduceTask(produceTask) {
|
|
|
+ console.log('produceTask', produceTask);
|
|
|
+ this.form.produceTaskId = produceTask.id;
|
|
|
+ this.form.produceTaskName = produceTask.name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped lang="scss"></style>
|