Commit 525201ff authored by AiNoeLiYa's avatar AiNoeLiYa

完善了基础工序管理里模拟数据的增删改查功能

parent 27c3e111
...@@ -45,12 +45,7 @@ ...@@ -45,12 +45,7 @@
</el-form-item> </el-form-item>
<div style="float: right"> <div style="float: right">
<el-form-item> <el-form-item>
<coolbutton style="padding: 8px 7px;" :type="typePrimary" :name="addName" :size="smallSize" :icon="addIcon" :haspermi="addHaspermi" @btn-click="handleAdd" /> <coolbutton style="padding: 8px 7px;" :type="typePrimary" :name="addName" :size="smallSize" :icon="addIcon" @btn-click="handleAdd" />
<!-- TODO:导入 -->
<coolbutton style="padding: 8px 7px;" :type="typeSuccess" :name="channelName" :size="smallSize" :icon="exportIcon" :haspermi="exportHaspermi" @btn-click="handleExport" />
<!-- 导出 -->
<coolbutton style="padding: 8px 7px;" :type="typeSuccess" :name="exportName" :size="smallSize" :icon="exportIcon" :haspermi="exportHaspermi" @btn-click="handleExport" />
</el-form-item> </el-form-item>
</div> </div>
</el-form> </el-form>
...@@ -101,7 +96,9 @@ ...@@ -101,7 +96,9 @@
</el-table-column> </el-table-column>
<el-table-column label="操作" class-name="small-padding fixed-width" width="240px"> <el-table-column label="操作" class-name="small-padding fixed-width" width="240px">
<template slot-scope="scope"> <template slot-scope="scope">
<coolbutton style="color: #49cec9" :type="typeParent" :name="updataName" :size="size" :haspermi="updateHaspermi" @btn-click="handleUpdate(scope.row)" /> <el-button style="color: #49cec9" :type="typeParent" :size="size" @click="handleUpdate(scope.row)">
{{ updataName }}
</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
...@@ -122,10 +119,10 @@ ...@@ -122,10 +119,10 @@
<!-- TODO: 添加或修改工序配置对话框 --> <!-- TODO: 添加或修改工序配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
<el-form-item label="名称" prop="roleName"> <el-form-item label="名称" prop="processName">
<el-input v-model.trim="form.processName" show-word-limit :maxlength="30" placeholder="请输入工序名称" /> <el-input v-model.trim="form.processName" show-word-limit :maxlength="30" placeholder="请输入工序名称" />
</el-form-item> </el-form-item>
<el-form-item label="工厂车间" prop="roleKey"> <el-form-item label="工厂车间" prop="workshop">
<el-input v-model.trim="form.workshop" show-word-limit :maxlength="30" placeholder="请输入工厂车间" /> <el-input v-model.trim="form.workshop" show-word-limit :maxlength="30" placeholder="请输入工厂车间" />
</el-form-item> </el-form-item>
<el-form-item label="状态"> <el-form-item label="状态">
...@@ -138,7 +135,7 @@ ...@@ -138,7 +135,7 @@
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="cancel">取 消</el-button> <el-button @click="cancel">取 消</el-button>
<el-button type="primary" @click="submitForm(form)">确 定</el-button> <el-button type="primary" @click="submitForm">确 定</el-button>
</div> </div>
</el-dialog> </el-dialog>
...@@ -146,6 +143,7 @@ ...@@ -146,6 +143,7 @@
</template> </template>
<script> <script>
// TODO: 导入外部已经封装好的button组件
import Coolbutton from '@/components/coolbutton' import Coolbutton from '@/components/coolbutton'
export default { export default {
name: 'Role', name: 'Role',
...@@ -158,8 +156,6 @@ export default { ...@@ -158,8 +156,6 @@ export default {
nameParent: '删除', nameParent: '删除',
resetName: '重置', resetName: '重置',
addName: '新增', addName: '新增',
channelName: '导入',
exportName: '导出',
updataName: '修改', updataName: '修改',
size: 'mini', size: 'mini',
smallSize: 'small', smallSize: 'small',
...@@ -235,33 +231,42 @@ export default { ...@@ -235,33 +231,42 @@ export default {
workshop: undefined, workshop: undefined,
flag: undefined flag: undefined
}, },
formReset: { defaultProps: {},
// 表单参数
form: {
processName: '', processName: '',
workshop: '', workshop: '',
flag: 0, flag: '1',
remark: '',
createTime: new Date(), createTime: new Date(),
updataTime: new Date(), updataTime: new Date(),
createBy: '' createBy: ''
}, },
// 表单参数 formReset: {
form: {
processName: '', processName: '',
workshop: '', workshop: '',
flag: 0, flag: '1',
createTime: new Date(), createTime: new Date(),
updataTime: new Date(), updataTime: new Date(),
createBy: '' createBy: ''
}, },
defaultProps: {
children: 'children',
label: 'label'
},
// 表单校验
rules: {},
deptOptions: [],
// TODO: 模拟测试数据 // TODO: 模拟测试数据
simulateProcessList: [{ processName: '打磨', workshop: '车间1', flag: 1, createTime: new Date(), updataTime: new Date(), createBy: '张三' }, { processName: '焊接', workshop: '车间2', flag: 2, createTime: new Date(), updataTime: new Date(), createBy: '李四' }] simulateProcessList: [{ processName: '打磨', workshop: '车间1', flag: 1, createTime: new Date(), updataTime: new Date(), createBy: '张三' }, { processName: '焊接', workshop: '车间2', flag: 2, createTime: new Date(), updataTime: new Date(), createBy: '李四' }],
// 表单校验
rules: {
processName: [
{ required: true, message: '请输入工序名称', trigger: 'blur' },
{ min: 2, max: 5, message: '长度在 2 到 5 个字符', trigger: 'blur' }
],
workshop: [
{ required: true, message: '请输入车间名称', trigger: 'blur' }
],
flag: [
{ required: true, trigger: 'blur' }
]
},
deptOptions: []
} }
}, },
/** 路由离开前存储筛选条件*/ /** 路由离开前存储筛选条件*/
...@@ -291,7 +296,21 @@ export default { ...@@ -291,7 +296,21 @@ export default {
this.loading = false this.loading = false
}, },
// 角色状态修改 // 角色状态修改
handleStatusChange(row) {}, handleStatusChange(row) {
const text = row.flag === '1' ? '启用' : '停用'
this.$confirm('是否确认操作?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$message({
message: text + '成功',
type: 'success'
})
}).catch(function() {
row.flag = row.flag === '0' ? '1' : '0'
})
},
// 取消按钮 // 取消按钮
cancel() { cancel() {
this.open = false this.open = false
...@@ -299,6 +318,7 @@ export default { ...@@ -299,6 +318,7 @@ export default {
}, },
// 表单重置 // 表单重置
reset() { reset() {
// TODO: 将模拟数据的空对象赋值给表单对象,达成清空填写表单的效果
this.form = this.formReset this.form = this.formReset
}, },
/** TODO: 查询按钮操作 */ /** TODO: 查询按钮操作 */
...@@ -312,25 +332,88 @@ export default { ...@@ -312,25 +332,88 @@ export default {
handleSelectionChange(selection) {}, handleSelectionChange(selection) {},
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
// TODO: 初始化新增对话框的状态
this.form = this.formReset
this.title = '添加工序'
this.open = !this.open this.open = !this.open
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) {}, handleUpdate(row) {
/** 提交按钮 */ this.reset()
submitForm: function(form) { this.title = '修改工序'
if (form !== undefined && form !== null) { const updProcessName = row.processName
this.roleList.push(form) for (const pd of this.simulateProcessList) {
this.getList() if (pd.processName === updProcessName) {
this.reset() this.form = pd
this.open = !this.open }
} }
this.open = true
}, },
/** 提交按钮 */ /** TODO: 修改或增加list列表里的数据 */
submitDataScope: function() {}, submitForm: function() {
/** 删除按钮操作 */ this.$refs['form'].validate(valid => {
handleDelete(row) {}, if (valid) {
/** 导出按钮操作 */ // TODO: 模拟测试数据的修改,可删除
handleExport() {} for (const p of this.simulateProcessList) {
if (p.processName === this.form.processName) {
this.simulateProcessList = this.simulateProcessList.map(obj =>
obj.processName === this.form.processName ? this.form : obj
)
this.msgSuccess('修改成功')
this.getList()
this.reset()
this.open = !this.open
return
} else {
if (this.form !== undefined && this.form !== null) {
this.simulateProcessList.push(this.form)
this.msgSuccess('新增成功')
this.getList()
this.reset()
this.open = !this.open
return
}
}
}
}
})
},
/** TODO: 关于模拟数据的 删除list数组所调用的删除方法,封装的函数如下 */
delProcess(delProcessName) {
let tip = false
for (const pd0 of this.simulateProcessList) {
console.log('This is pd0:', pd0)
if (pd0.processName === delProcessName) {
this.simulateProcessList = this.simulateProcessList.filter(item => item.processName !== delProcessName)
tip = true
break
}
}
return tip
},
/** TODO:删除按钮操作 */
handleDelete(row) {
this.$confirm('是否确认操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
return this.delProcess(row.processName)
}).then(() => {
this.getList()
this.$message({
message: '删除成功',
type: 'success'
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
}
} }
} }
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment