Commit beb91c0d by lichengming

修改了模板管理的编辑按钮

parent 35f0e3ec
......@@ -10,6 +10,10 @@ export default {
http.post('meter/v1/file_template/page', data).then(res => res),
getById: data => http.get('meter/v1/file_template/' + data).then(res => res),
edit: data =>
http
.put('meter/v1/file_template/' + data.id, data.formObj)
.then(res => res),
deleteById: data =>
http.delete('meter/v1/file_template/?ids=' + data).then(res => res)
}
<template>
<div>
<Modal v-model="showEditModal" :mask-closable="false">
<p slot="header">{{modalTitle}}</p>
<div v-show="isLoad">
<Spin fix>
<Icon type="load-c" size=18 class="file-spin-icon-load"></Icon>
<div>正在上传,请稍后...</div>
</Spin>
</div>
<div>
<Form id="edit-form" ref="formObj" :model="formObj" :rules="ruleValidate" :label-width="80">
<Form-item label="类别" prop="classType">
<!-- <Input v-model="formObj.classType" @on-keyup="_onKeyUp" name="classType" placeholder="请选择类别" icon="plus-circled"-->
<!-- ></Input>-->
<el-select v-model="formObj.classType" placeholder="请选择类别" size="small" clearable>
<el-option :label="item.value" :value="item.value" v-for="(item,index) in typeList"
:key="index"></el-option>
</el-select>
</Form-item>
<Form-item label="别名" prop="alias">
<Input v-model="formObj.alias" name="alias" placeholder="请输入别名"></Input>
</Form-item>
<Form-item label="项目代号" prop="remark">
<Input v-model="formObj.remark" name="remark" placeholder="请输入项目代号"></Input>
</Form-item>
</Form>
</div>
<div slot="footer" class="btn-width clearfix">
<Button @click="_cancel" style="margin-left: 8px;">取消</Button>
<Button @click="_ok" type="primary" style="margin-bottom: 0;float: right">保存</Button>
<!-- <label style="margin-bottom: 0;float: right">-->
<!-- <Upload-->
<!-- :action="action"-->
<!-- :on-success="_handelsuccess"-->
<!-- :before-upload="_beupload"-->
<!-- :on-progress="_handelprogress"-->
<!-- :on-format-error="_formatError"-->
<!-- :data="dataObj"-->
<!-- :with-credentials="true"-->
<!-- :show-upload-list="false"-->
<!-- :format="format"-->
<!-- >-->
<!-- <Button :disabled="isDisable" type="primary">导入文件</Button>-->
<!-- </Upload>-->
<!-- </label>-->
</div>
</Modal>
<!--类别弹出树-->
<!-- <LmsTemplateClassifyZTree ref="ztreeModal" @on-result-change="_ztree"></LmsTemplateClassifyZTree>-->
</div>
</template>
<script>
/**
* 添加编辑
*/
// import LmsTemplateClassifyZTree from '../lms-template-classify/LmsTemplateClassifyZTree.vue'
// import global from '../../../api/config'
import { meterTemplate } from '../../../api'
const defVal = {
alias: '',
classType: '',
remark: '',
classifyId: 0
}
export default {
// components: { LmsTemplateClassifyZTree },
data() {
return {
modalTitle: '添加',
formObj: defVal,
ruleValidate: {
alias: [{ required: true, message: '别名不能为空', trigger: 'blur' }],
remark: [
{ required: true, message: '项目代号不能为空', trigger: 'blur' }
],
classType: [
{ required: true, message: '类别不能为空', trigger: 'blur' }
]
},
typeList: [
{
value: '检定证书模板'
},
{
value: '校准证书模板'
}
],
id: '',
showEditModal: false,
dataObj: {
file: ''
},
pname: '',
action: '',
isLoad: false,
isDisable: true,
format: ['docx', 'xlsx', 'xls']
}
},
methods: {
_onKeyUp() {
if (
this.formObj.alias === '' ||
this.formObj.classType === '' ||
this.formObj.remark === ''
) {
this.isDisable = true
} else {
this.isDisable = false
this.action =
global.baseURL +
'/meter/v1/file_template/upload_template/?classType=' +
this.formObj.classType +
'&alias=' +
this.formObj.alias +
'&remark=' +
this.formObj.remark
}
},
_selectZtree() {
// this.$refs.ztreeModal._openZtree()
},
_cancel() {
this.showEditModal = false
},
_ok: async function() {
const result = await meterTemplate.edit({
id: this.id,
formObj: this.formObj
})
if (result) {
this.$message.success('编辑成功')
this.showEditModal = false
this.$emit('on-result-change')
}
},
_open(data) {
console.log(data)
this.showEditModal = true
this.isLoad = false
this.id = data.id
this.formObj.alias = data.alias
this.formObj.remark = data.remark
this.formObj.classType = data.classType
this.modalTitle = '编辑模板'
console.log(this.id)
},
_beupload(file) {
this.dataObj.file = file.name
},
_handelprogress(event, file, fileList) {
this.isLoad = true
},
// _handelsuccess(response, file, fileList) {
// // 上传成功
// if (response.success) {
// this.isLoad = false
// this.$Message.success('上传成功!')
// this.$emit('on-result-change')
// this.showEditModal = false
// } else {
// this.isLoad = true
// this.$Message.error(response.msg)
// }
// },
_formatError(file) {
this.$Notice.error({
title: '文件格式不正确',
duration: 10,
desc:
'文件 ' +
file.name +
' 格式不正确,请上传格式为 docx、xlsx、xls 的文件!'
})
},
_ztree(result) {
this.pname = ''
if (result === undefined) {
this.formObj.classifyId = '0'
this.pname = ''
} else {
this.formObj.classifyId = result.id
this.pname = result.name
}
// 判断必填项是否为空
}
}
}
</script>
<style scoped>
.clearfix:after {
content: '';
clear: both;
display: block;
}
</style>
......@@ -7,14 +7,14 @@
<Row>
<!--查询-->
<Col span="24">
<Form v-show="searchOpen" id="search-form" :label-width="80" inline onsubmit="return false">
<Form id="search-form" v-show="searchOpen" :label-width="80" inline onsubmit="return false">
<label class="label-sign"></label>
<Form-item class="search-item" label="模板名称:">
<Input v-model="formObj.name" name="name" placeholder="请输入模板名称" @on-enter="_formSearch"></Input>
<Input v-model="formObj.name" @on-enter="_formSearch" name="name" placeholder="请输入模板名称"></Input>
<input type="hidden" name="classifyId">
</Form-item>
<Form-item class="search-btn">
<Button type="primary" @click="_formSearch">搜索</Button>
<Button @click="_formSearch" type="primary">搜索</Button>
</Form-item>
</Form>
</Col>
......@@ -45,16 +45,19 @@
</div>
<!-- 添加、编辑 -->
<FoodReportTemplateEdit ref="editModal" @on-result-change="_search"></FoodReportTemplateEdit>
<MeterReportEdit ref="reportEdit" @on-result-change="_search"></MeterReportEdit>
</div>
</template>
<script>
import global from '../../../api/config'
import { meterTemplate } from '../../../api'
import FoodReportTemplateEdit from './MeterReportTemplateEdit'
import MeterReportEdit from './MeterReportEdit'
export default {
components: {
FoodReportTemplateEdit
FoodReportTemplateEdit,
MeterReportEdit
},
data() {
return {
......@@ -68,6 +71,7 @@ export default {
name: undefined
},
iconMsg: [
{ type: 'md-create', id: '', name: '编辑' },
{ type: 'ios-book', id: '', name: '预览/编辑' },
// { type: 'ios-download', id: '', name: '下载' },
{ type: 'md-remove-circle', id: '', name: '删除' }
......@@ -135,6 +139,9 @@ export default {
},
_iconClick(res, data) {
switch (res) {
case '编辑':
this._reportEdit(data)
break
case '下载':
this._download(data.id)
break
......@@ -187,6 +194,9 @@ export default {
_editModal() {
this.$refs.editModal._open()
},
_reportEdit(data) {
this.$refs.reportEdit._open(data)
},
// 批量删除
_delAll() {
const ids = this.selectIds
......
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