ziliangshangchuang
This commit is contained in:
parent
5ee5971719
commit
6d75de80d5
|
@ -4,9 +4,9 @@ ENV = 'development'
|
|||
# base api
|
||||
#VUE_APP_BASE_API = 'http://10.0.11.127:8000/api'
|
||||
#VUE_APP_BASE_API = 'http://127.0.0.1:8000/api'
|
||||
VUE_APP_BASE_API = 'https://testsearch.ctc.ac.cn/api'
|
||||
#VUE_APP_BASE_API = 'https://testsearch.ctc.ac.cn/api'
|
||||
|
||||
#VUE_APP_BASE_API = 'http://47.95.0.242:9101'
|
||||
VUE_APP_BASE_API = 'http://47.95.0.242:9101/api'
|
||||
|
||||
|
||||
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
|
||||
|
|
|
@ -49,3 +49,31 @@ export function deletes(data)
|
|||
data
|
||||
})
|
||||
}
|
||||
export function createDocument(data) {
|
||||
return request({
|
||||
url: '/quality/document/',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function getDocumentList(query) {
|
||||
return request({
|
||||
url: '/quality/document/',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
export function deleteDocument(id) {
|
||||
return request({
|
||||
url: `/quality/document/${id}/`,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
export function updateDocument(id, data) {
|
||||
return request({
|
||||
url: `/quality/document/${id}/`,
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
|
@ -194,7 +194,12 @@ export const asyncRoutes = [
|
|||
meta: { title: '任务执行', perms: ['my_inspecttask'] },
|
||||
hidden: true
|
||||
},
|
||||
|
||||
{
|
||||
path: 'InspectDoc',
|
||||
name: 'InspectDoc',
|
||||
component: () => import('@/views/qualityinspect/inspectdoc.vue'),
|
||||
meta: { title: '质量文档', perms: ['inspectdoc'] }
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -0,0 +1,274 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<el-card>
|
||||
<el-button type="primary" icon="el-icon-plus" @click="handleAddContent"
|
||||
>新增</el-button
|
||||
>
|
||||
</el-card>
|
||||
<el-card style="margin-top: 10px">
|
||||
<el-table
|
||||
v-loading="listLoading"
|
||||
:data="contentList.results"
|
||||
border
|
||||
fit
|
||||
stripe
|
||||
highlight-current-row
|
||||
max-height="600"
|
||||
>
|
||||
<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 label="文件描述">
|
||||
<template slot-scope="scope">{{ scope.row.description }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="文件格式">
|
||||
<template slot-scope="scope">{{ scope.row.file_.mime }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="文件下载">
|
||||
<template slot-scope="scope" v-if="scope.row.file_.file">
|
||||
<el-link :href="scope.row.file_.file" type="primary">下载</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
label="操作"
|
||||
width="200px"
|
||||
fixed="right"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
:disabled="!checkPermission(['content'])"
|
||||
type="primary"
|
||||
size="small"
|
||||
icon="el-icon-edit"
|
||||
@click="handleEdit(scope)"
|
||||
/>
|
||||
<el-button
|
||||
:disabled="!checkPermission(['content'])"
|
||||
type="danger"
|
||||
size="small"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="contentList.count > 0"
|
||||
:total="contentList.count"
|
||||
:page.sync="listQuery.page"
|
||||
:limit.sync="listQuery.page_size"
|
||||
@pagination="getDocumentList"
|
||||
/>
|
||||
</el-card>
|
||||
<el-dialog
|
||||
:visible.sync="dialogVisible"
|
||||
:title="dialogType === 'edit' ? '编辑资料' : '新增资料'"
|
||||
>
|
||||
<el-form
|
||||
ref="Form"
|
||||
:model="Content"
|
||||
label-width="80px"
|
||||
label-position="right"
|
||||
:rules="rule1"
|
||||
>
|
||||
<el-form-item label="文档名称" prop="name">
|
||||
<el-input v-model="Content.name" placeholder="文档名称" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="" prop="description">
|
||||
<el-input
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
v-model="Content.description"
|
||||
placeholder="文档描述"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="文档描述" prop="file" v-if="dialogVisible">
|
||||
<el-upload
|
||||
ref="upload"
|
||||
:action="upUrl"
|
||||
:on-preview="handlePreview"
|
||||
:on-success="handleUpSuccess"
|
||||
:on-remove="handleRemove"
|
||||
:headers="upHeaders"
|
||||
:file-list="fileList"
|
||||
:limit="1"
|
||||
accept=".doc,.docx,.xls,.xlsx,.ppt,.pptx"
|
||||
>
|
||||
<el-button size="small" type="primary">上传文件</el-button>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
<div style="text-align: right">
|
||||
<el-button type="danger" @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="confirm('Form')">确认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import {
|
||||
getDocumentList,
|
||||
createDocument,
|
||||
deleteDocument,
|
||||
updateDocument,
|
||||
} from "@/api/inspection";
|
||||
import { genTree } from "@/utils";
|
||||
import checkPermission from "@/utils/permission";
|
||||
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
|
||||
import Treeselect from "@riophae/vue-treeselect";
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
import { getDictList, getDictTypeList } from "@/api/dict";
|
||||
import { upUrl, upHeaders } from "@/api/file";
|
||||
const defaultContent = {
|
||||
name: "",
|
||||
description: "",
|
||||
file:null
|
||||
};
|
||||
export default {
|
||||
components: { Pagination, Treeselect },
|
||||
data() {
|
||||
return {
|
||||
upHeaders: upHeaders(),
|
||||
upUrl: upUrl(),
|
||||
fileList:[],
|
||||
Content: defaultContent,
|
||||
|
||||
typeOptions: [],
|
||||
listLoading: true,
|
||||
dialogVisible: false,
|
||||
listQuery: {
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
},
|
||||
contentList: {
|
||||
count:0
|
||||
},
|
||||
dialogType: "new",
|
||||
rule1: {
|
||||
name: [{ required: true, message: "请输入名称", trigger: "blur" }],
|
||||
},
|
||||
filterOrgText: "",
|
||||
treeLoding: false,
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
watch: {
|
||||
filterOrgText(val) {
|
||||
this.$refs.tree.filter(val);
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
|
||||
},
|
||||
methods: {
|
||||
handlePreview(file) {
|
||||
if ("url" in file) {
|
||||
window.open(file.url);
|
||||
} else {
|
||||
window.open(file.response.data.path);
|
||||
}
|
||||
},
|
||||
handleUpSuccess(res, file, filelist) {
|
||||
this.Content.file = res.data.id;
|
||||
|
||||
},
|
||||
handleRemove(file, filelist){
|
||||
this.Content.file = null;
|
||||
},
|
||||
checkPermission,
|
||||
|
||||
filterNode(value, data) {
|
||||
if (!value) return true;
|
||||
return data.label.indexOf(value) !== -1;
|
||||
},
|
||||
|
||||
getList() {
|
||||
this.listLoading = true;
|
||||
getDocumentList().then((response) => {
|
||||
if (response.data) {
|
||||
this.contentList = response.data;
|
||||
}
|
||||
this.listLoading = false;
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
handleFilter() {
|
||||
this.listQuery.page = 1;
|
||||
this.getList();
|
||||
},
|
||||
handleAddContent() {
|
||||
this.Content = Object.assign({}, defaultContent);
|
||||
this.dialogType = "new";
|
||||
this.dialogVisible = true;
|
||||
this.fileList=[]
|
||||
this.$nextTick(() => {
|
||||
this.$refs["Form"].clearValidate();
|
||||
});
|
||||
},
|
||||
handleEdit(scope) {
|
||||
this.Content = Object.assign({}, scope.row); // copy obj
|
||||
this.dialogType = "edit";
|
||||
this.dialogVisible = true;
|
||||
if (this.Content.file) {
|
||||
this.fileList = [
|
||||
{
|
||||
name:this.Content.file_.name,
|
||||
url: this.Content.file,
|
||||
},
|
||||
];
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
this.$refs["Form"].clearValidate();
|
||||
});
|
||||
},
|
||||
handleDelete(scope) {
|
||||
this.$confirm("确认删除?", "警告", {
|
||||
confirmButtonText: "确认",
|
||||
cancelButtonText: "取消",
|
||||
type: "error",
|
||||
})
|
||||
.then(async () => {
|
||||
await deleteDocument(scope.row.id);
|
||||
this.getList();
|
||||
this.$message.success("成功");
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
});
|
||||
},
|
||||
async confirm(form) {
|
||||
this.$refs[form].validate((valid) => {
|
||||
if (valid) {
|
||||
const isEdit = this.dialogType === "edit";
|
||||
if (isEdit) {
|
||||
console.log(this.Content)
|
||||
updateDocument(this.Content.id, this.Content).then((res) => {
|
||||
if (res.code >= 200) {
|
||||
this.getList();
|
||||
this.dialogVisible = false;
|
||||
this.$message.success("成功");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
createDocument(this.Content).then((res) => {
|
||||
if (res.code >= 200) {
|
||||
this.getList();
|
||||
this.dialogVisible = false;
|
||||
this.$message.success("成功");
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
Loading…
Reference in New Issue