Merge branch 'master' of https://e.coding.net/ctcdevteam/cnas
This commit is contained in:
commit
8f74257841
|
@ -38,7 +38,7 @@
|
|||
>刷新重置</el-button>
|
||||
</div>
|
||||
<div style="margin-top:6px">
|
||||
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
|
||||
<el-button type="primary" icon="el-icon-plus" @click="handleCreate">新增</el-button>
|
||||
</div>
|
||||
<el-table
|
||||
v-loading="listLoading"
|
||||
|
@ -69,6 +69,24 @@
|
|||
<el-table-column align="header-center" label="状态">
|
||||
<template slot-scope="scope">{{ scope.row.status }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
icon="el-icon-edit"
|
||||
:disabled="!checkPermission(['standard_update'])"
|
||||
@click="handleUpdate(scope)"
|
||||
/>
|
||||
<el-button
|
||||
type="danger"
|
||||
size="small"
|
||||
icon="el-icon-delete"
|
||||
:disabled="!checkPermission(['standard_delete'])"
|
||||
@click="handleDelete(scope)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="standardList.count>0"
|
||||
|
@ -106,29 +124,36 @@
|
|||
<el-form-item label="发布日期" prop="publish_date">
|
||||
<el-date-picker
|
||||
v-model="standard.publish_date"
|
||||
value-format="yyyy-MM-dd"
|
||||
type="date"
|
||||
placeholder="选择日期">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="实施日期" prop="implement_date">
|
||||
<el-date-picker
|
||||
|
||||
v-model="standard.implement_date"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="选择日期">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-form-item label="文件" prop="path">
|
||||
<el-form-item label="文件" prop="path">
|
||||
<el-upload
|
||||
v-if="standard.path"
|
||||
|
||||
:on-preview="handlePreview"
|
||||
:on-success="handleSuccess"
|
||||
:action="upUrl"
|
||||
:headers="upHeaders"
|
||||
:show-file-list="false"
|
||||
:limit="1"
|
||||
:file-list="fileList"
|
||||
>
|
||||
<el-button size="small" type="primary">点击上传</el-button>
|
||||
<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>
|
||||
|
@ -137,9 +162,10 @@
|
|||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { getStandardList } from "@/api/standard"
|
||||
import { getStandardList, createStandard, updateStandard, deleteStandard } from "@/api/standard"
|
||||
import { upUrl, upHeaders} from "@/api/file"
|
||||
import Pagination from "@/components/Pagination"
|
||||
import checkPermission from '@/utils/permission'
|
||||
const defaultStandard = {
|
||||
id:null,
|
||||
code:null,
|
||||
|
@ -175,13 +201,15 @@ export default {
|
|||
publish_date: [{ required: true, message: "请输入发布日期", trigger: "change" }],
|
||||
implement_date: [{ required: true, message: "请输入实施日期", trigger: "change" }],
|
||||
status: [{ required: true, message: "请选择状态", trigger: "change" }]
|
||||
}
|
||||
},
|
||||
fileList:[]
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
checkPermission,
|
||||
getList() {
|
||||
this.listLoading = true;
|
||||
getStandardList(this.listQuery).then(response => {
|
||||
|
@ -202,14 +230,73 @@ export default {
|
|||
this.listQuery.page = 1;
|
||||
this.getList();
|
||||
},
|
||||
handleAdd() {
|
||||
handleCreate() {
|
||||
this.standard = Object.assign({}, defaultStandard);
|
||||
this.fileList = []
|
||||
this.dialogType = "create";
|
||||
this.dialogVisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs["Form"].clearValidate();
|
||||
});
|
||||
},
|
||||
handleUpdate(scope) {
|
||||
this.standard = Object.assign({}, scope.row) // copy obj
|
||||
if(this.standard.path){
|
||||
this.fileList=[{
|
||||
name:this.standard.code + this.standard.name,
|
||||
url:this.standard.path
|
||||
}]
|
||||
}
|
||||
this.dialogType = 'update'
|
||||
this.dialogVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['Form'].clearValidate()
|
||||
})
|
||||
},
|
||||
handlePreview(file) {
|
||||
if ('url' in file){
|
||||
window.open(file.url)
|
||||
}else{
|
||||
window.open(file.response.data.path)
|
||||
}
|
||||
|
||||
},
|
||||
handleSuccess(response, file, fileList) {
|
||||
this.standard.path = response.data.path
|
||||
},
|
||||
async confirm(form) {
|
||||
this.$refs[form].validate(valid => {
|
||||
if (valid) {
|
||||
const isEdit = this.dialogType === "edit";
|
||||
if (isEdit) {
|
||||
updateUser(this.user.id, this.user).then(res => {
|
||||
if (res.code >= 200) {
|
||||
this.getList();
|
||||
this.dialogVisible = false
|
||||
this.$notify({
|
||||
title: "成功",
|
||||
message: "编辑成功",
|
||||
type: "success",
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
createStandard(this.standard).then(res => {
|
||||
this.getList();
|
||||
this.dialogVisible = false
|
||||
this.$notify({
|
||||
title: "成功",
|
||||
type: "success",
|
||||
})
|
||||
|
||||
}).catch(error=>{})
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -319,7 +319,6 @@ export default {
|
|||
const isEdit = this.dgT1 === 'edit'
|
||||
if (isEdit) {
|
||||
updateDictType(this.dicttype.id, this.dicttype).then(res => {
|
||||
if (res.code >= 200) {
|
||||
this.getDictTypeList()
|
||||
this.dgV1 = false
|
||||
this.$notify({
|
||||
|
@ -328,11 +327,9 @@ export default {
|
|||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})
|
||||
}).catch(error=>{})
|
||||
} else {
|
||||
createDictType(this.dicttype).then(res => {
|
||||
if (res.code >= 200) {
|
||||
this.getDictTypeList()
|
||||
this.dgV1 = false
|
||||
this.$notify({
|
||||
|
@ -341,8 +338,7 @@ export default {
|
|||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})
|
||||
}).catch(error=>{})
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
|
@ -355,7 +351,6 @@ export default {
|
|||
const isEdit = this.dgT2 === 'edit'
|
||||
if (isEdit) {
|
||||
updateDict(this.dict.id, this.dict).then(res => {
|
||||
if (res.code >= 200) {
|
||||
this.getList()
|
||||
this.dgV2 = false
|
||||
this.$notify({
|
||||
|
@ -364,11 +359,9 @@ export default {
|
|||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})
|
||||
}).catch(error=>{})
|
||||
} else {
|
||||
createDict(this.dict).then(res => {
|
||||
if (res.code >= 200) {
|
||||
this.getList()
|
||||
this.dgV2 = false
|
||||
this.$notify({
|
||||
|
@ -377,8 +370,7 @@ export default {
|
|||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})
|
||||
}).catch(error=>{})
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
|
|
|
@ -250,11 +250,7 @@ export default {
|
|||
methods: {
|
||||
checkPermission,
|
||||
handleAvatarSuccess(res, file) {
|
||||
if (res.code >= 200) {
|
||||
this.user.avatar = res.data.path
|
||||
} else {
|
||||
this.$message.error("头像上传失败!")
|
||||
}
|
||||
},
|
||||
beforeAvatarUpload(file) {
|
||||
const isLt2M = file.size / 1024 / 1024 < 2;
|
||||
|
@ -344,7 +340,6 @@ export default {
|
|||
const isEdit = this.dialogType === "edit";
|
||||
if (isEdit) {
|
||||
updateUser(this.user.id, this.user).then(res => {
|
||||
if (res.code >= 200) {
|
||||
this.getList();
|
||||
this.dialogVisible = false;
|
||||
this.$notify({
|
||||
|
@ -353,11 +348,9 @@ export default {
|
|||
type: "success",
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
createUser(this.user).then(res => {
|
||||
if (res.code >= 200) {
|
||||
this.getList();
|
||||
this.dialogVisible = false;
|
||||
this.$notify({
|
||||
|
@ -366,7 +359,6 @@ export default {
|
|||
type: "success",
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.0.7 on 2020-06-16 09:20
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('certset', '0003_auto_20200616_1158'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='unittype',
|
||||
name='description',
|
||||
field=models.TextField(blank=True, null=True, verbose_name='描述'),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.0.7 on 2020-06-16 09:20
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('system', '0019_auto_20200612_1448'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='file',
|
||||
name='name',
|
||||
field=models.CharField(blank=True, max_length=300, null=True, verbose_name='名称'),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.0.7 on 2020-06-16 09:22
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('system', '0020_auto_20200616_1720'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='file',
|
||||
name='mime',
|
||||
field=models.CharField(blank=True, max_length=300, null=True, verbose_name='文件格式'),
|
||||
),
|
||||
]
|
|
@ -2,30 +2,24 @@ from rest_framework import status
|
|||
from rest_framework.response import Response
|
||||
from rest_framework.settings import api_settings
|
||||
|
||||
class CreateModelAMixin:
|
||||
class CreateUpdateModelAMixin:
|
||||
"""
|
||||
业务用基本表A用
|
||||
"""
|
||||
def perform_create(self, serializer):
|
||||
serializer.save(create_by = self.request.user)
|
||||
|
||||
class UpdateModelAMixin:
|
||||
"""
|
||||
业务用基本表A用
|
||||
"""
|
||||
|
||||
def perform_update(self, serializer):
|
||||
serializer.save(update_by = self.request.user)
|
||||
|
||||
class CreateModelBMixin:
|
||||
class CreateUpdateModelBMixin:
|
||||
"""
|
||||
业务用基本表B用
|
||||
"""
|
||||
def perform_create(self, serializer):
|
||||
serializer.save(create_by = self.request.user, belong_dept=self.request.user.dept)
|
||||
|
||||
class UpdateModelBMixin:
|
||||
"""
|
||||
业务用基本表B用
|
||||
"""
|
||||
|
||||
def perform_update(self, serializer):
|
||||
serializer.save(update_by = self.request.user)
|
||||
serializer.save(update_by = self.request.user)
|
||||
|
||||
|
|
@ -198,7 +198,7 @@ class File(CommonAModel):
|
|||
"""
|
||||
文件存储表,业务表根据具体情况选择是否外键关联
|
||||
"""
|
||||
name = models.CharField('名称', max_length=30, null=True, blank=True)
|
||||
name = models.CharField('名称', max_length=300, null=True, blank=True)
|
||||
size = models.IntegerField('文件大小', default=1, null=True, blank=True)
|
||||
file = models.FileField('文件', upload_to='%Y/%m/%d/')
|
||||
type_choices = (
|
||||
|
@ -208,7 +208,7 @@ class File(CommonAModel):
|
|||
('图片', '图片'),
|
||||
('其它', '其它')
|
||||
)
|
||||
mime = models.CharField('文件格式', max_length=50, null=True, blank=True)
|
||||
mime = models.CharField('文件格式', max_length=300, null=True, blank=True)
|
||||
type = models.CharField('文件类型', max_length=50, choices=type_choices, default='文档')
|
||||
path = models.CharField('地址', max_length=1000, null=True, blank=True)
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ from rest_framework_simplejwt.tokens import RefreshToken
|
|||
from utils.queryset import get_child_queryset2
|
||||
|
||||
from .filters import UserFilter
|
||||
from .mixins import CreateModelAMixin
|
||||
from .mixins import CreateUpdateModelAMixin
|
||||
from .models import (Dict, DictType, File, Organization, Permission, Position,
|
||||
Role, User)
|
||||
from .permission import RbacPermission, get_permission_list
|
||||
|
@ -233,7 +233,7 @@ class UserViewSet(ModelViewSet):
|
|||
}
|
||||
return Response(data)
|
||||
|
||||
class FileViewSet(ModelViewSet):
|
||||
class FileViewSet(CreateUpdateModelAMixin, ModelViewSet):
|
||||
"""
|
||||
文件:增删改查
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue