|
@@ -6,7 +6,7 @@
|
|
|
<div class="one_left">
|
|
|
<div class="button" @click="toAdd">发布项目</div>
|
|
|
<div class="button" @click="toTemplate">下载导出模板</div>
|
|
|
- <div class="button" @click="toUExcel">上传Excel</div>
|
|
|
+ <el-upload class="button" :action="url" :show-file-list="false" :on-error="onError" :http-request="httpRequse" accept=".xlsx"> 选择excel模板文件 </el-upload>
|
|
|
<div class="button" @click="toDownload">下载Excel</div>
|
|
|
</div>
|
|
|
<div class="one_right">
|
|
@@ -102,6 +102,19 @@
|
|
|
</div>
|
|
|
</el-col>
|
|
|
</transition>
|
|
|
+ <el-col :span="24" class="dialog_thr" v-if="dialog.type == '3'">
|
|
|
+ <el-col :span="24" class="one">
|
|
|
+ <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="two">
|
|
|
+ <el-checkbox-group v-model="checkedExport" @change="checkedExportChange">
|
|
|
+ <el-checkbox v-for="i in formFields" :label="i" :key="i.model">{{ i.label }}</el-checkbox>
|
|
|
+ </el-checkbox-group>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="btn">
|
|
|
+ <el-button type="primary" size="mini" @click="toFile()">导出</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
</el-row>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
@@ -121,6 +134,8 @@ import { DictDataStore } from '@/store/api/system/dictData'
|
|
|
import { TagsStore } from '@/store/api/system/tags'
|
|
|
import { SectorStore } from '@/store/api/platform/sector'
|
|
|
import { RegionStore } from '@/store/api/system/region'
|
|
|
+import { UtilStore } from '@/store/api/util'
|
|
|
+const utilStore = UtilStore()
|
|
|
const regionStore = RegionStore()
|
|
|
const store = ProjectStore()
|
|
|
const dictDataStore = DictDataStore()
|
|
@@ -168,24 +183,28 @@ const form = ref({ file: [] })
|
|
|
const dialog = ref({ type: '1', show: false, title: '发布项目' })
|
|
|
const formFields = ref([
|
|
|
{ label: '项目名称', model: 'name' },
|
|
|
- { label: '标签', model: 'tags', custom: true },
|
|
|
+ { label: '标签', model: 'tags', custom: true, mark: 'tags' },
|
|
|
{ label: '所属产业', model: 'industry', type: 'select' },
|
|
|
- { label: '行业分类', model: 'type', type: 'select' },
|
|
|
- { label: '成熟度', model: 'maturity', type: 'select' },
|
|
|
- { label: '技术类型', model: 'skill', type: 'select' },
|
|
|
- { label: '行业领域', model: 'field', type: 'select' },
|
|
|
- { label: '合作类型', model: 'cooperate', type: 'select' },
|
|
|
- { label: '项目地区', model: 'area', custom: true },
|
|
|
+ { label: '行业分类', model: 'type', type: 'select', code: 'industry' },
|
|
|
+ { label: '成熟度', model: 'maturity', type: 'select', mark: 'dict', code: 'projectMaturity' },
|
|
|
+ { label: '技术类型', model: 'skill', type: 'select', mark: 'dict', code: 'technology' },
|
|
|
+ { label: '行业领域', model: 'field', type: 'select', mark: 'dict', code: 'field' },
|
|
|
+ { label: '合作类型', model: 'cooperate', type: 'select', mark: 'dict', code: 'projectType' },
|
|
|
+ { label: '项目地区', model: 'area', custom: true, mark: 'area' },
|
|
|
{ label: '发布时间', model: 'time', type: 'date' },
|
|
|
{ label: '项目主体', model: 'main' },
|
|
|
{ label: '项目进展', model: 'progress' },
|
|
|
{ label: '跟踪支持单位', model: 'track_unit' },
|
|
|
{ label: '项目来源', model: 'source' },
|
|
|
- { label: '是否启用', model: 'is_use', type: 'radio' },
|
|
|
+ { label: '是否启用', model: 'is_use', type: 'radio', mark: 'dict', code: 'isUse' },
|
|
|
{ label: '简介', model: 'brief', type: 'textarea' },
|
|
|
{ label: '附件', model: 'file', custom: true }
|
|
|
])
|
|
|
const rules = reactive({ name: [{ required: true, message: '请输入项目名称', trigger: 'blur' }] })
|
|
|
+// 导出文件
|
|
|
+const checkAll = ref(false)
|
|
|
+const checkedExport = ref([])
|
|
|
+const isIndeterminate = ref(true)
|
|
|
// 请求
|
|
|
onMounted(async () => {
|
|
|
loading.value = true
|
|
@@ -337,22 +356,70 @@ const getArea = (data) => {
|
|
|
if (data) return data.join('-')
|
|
|
else return '暂无地区'
|
|
|
}
|
|
|
+const toClose = () => {
|
|
|
+ checkedExport.value = []
|
|
|
+ checkAll.value = false
|
|
|
+ form.value = { time: [] }
|
|
|
+ width.value = '50%'
|
|
|
+ dialog.value = { show: false }
|
|
|
+}
|
|
|
+// 全选
|
|
|
+const handleCheckAllChange = (val) => {
|
|
|
+ checkedExport.value = val ? formFields.value : []
|
|
|
+ isIndeterminate.value = false
|
|
|
+}
|
|
|
+// 选择
|
|
|
+const checkedExportChange = (value) => {
|
|
|
+ let checkedCount = value.length
|
|
|
+ checkAll.value = checkedCount === formFields.value.length
|
|
|
+ isIndeterminate.value = checkedCount > 0 && checkedCount < formFields.value.length
|
|
|
+}
|
|
|
// 下载导出模板
|
|
|
const toTemplate = () => {
|
|
|
- console.log('下载导出模板')
|
|
|
+ window.open('/cxyyWeb/导入模板.xlsx')
|
|
|
}
|
|
|
// 上传Excel
|
|
|
-const toUExcel = () => {
|
|
|
- console.log('上传Excel')
|
|
|
+const httpRequse = async (param) => {
|
|
|
+ const msgbox = ElMessage({ message: '正在导入中,请稍后...', center: true, duration: 0 })
|
|
|
+ try {
|
|
|
+ let fileObj = param.file
|
|
|
+ let fd = new FormData()
|
|
|
+ fd.append('file', fileObj, fileObj.name)
|
|
|
+ const res = await utilStore.toImport(fd)
|
|
|
+ // let list
|
|
|
+ console.log(res)
|
|
|
+ // if (res.status !== 200) {
|
|
|
+ // list = [{ key: '请求发生错误' }]
|
|
|
+ // } else if (res.data.errcode !== 0) {
|
|
|
+ // list = [{ key: '请求发生错误', num: res.data.errmsg }]
|
|
|
+ // } else {
|
|
|
+ // list = res.data.data
|
|
|
+ // }
|
|
|
+ // console.log(list)
|
|
|
+ } catch (error) {
|
|
|
+ console.error(error)
|
|
|
+ } finally {
|
|
|
+ msgbox.close()
|
|
|
+ }
|
|
|
}
|
|
|
// 下载Excel
|
|
|
const toDownload = () => {
|
|
|
- console.log('下载Excel')
|
|
|
+ dialog.value = { type: '3', show: true, title: '下载Excel' }
|
|
|
}
|
|
|
-const toClose = () => {
|
|
|
- form.value = { file: [] }
|
|
|
- width.value = '50%'
|
|
|
- dialog.value = { show: false }
|
|
|
+
|
|
|
+// 导出Excel
|
|
|
+const toFile = async () => {
|
|
|
+ if (checkedExport.value.length > 0) {
|
|
|
+ const reqData = { table: 'project', config: checkedExport.value, user: user.value.id }
|
|
|
+ const res = await utilStore.toExport(reqData)
|
|
|
+ if ($checkRes(res, true)) {
|
|
|
+ ElMessage({ type: `success`, message: `导出成功` })
|
|
|
+ window.open(res.data)
|
|
|
+ }
|
|
|
+ toClose()
|
|
|
+ } else {
|
|
|
+ ElMessage({ type: `warning`, message: `请选择导出信息字段` })
|
|
|
+ }
|
|
|
}
|
|
|
// 分页
|
|
|
const changePage = (page = currentPage.value) => {
|
|
@@ -478,4 +545,21 @@ const sizeChange = (limits) => {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+.dialog_thr {
|
|
|
+ padding: 20px;
|
|
|
+
|
|
|
+ .one {
|
|
|
+ margin: 0 0 10px 0;
|
|
|
+ }
|
|
|
+ .two {
|
|
|
+ margin: 0 0 10px 0;
|
|
|
+ :deep(.el-checkbox) {
|
|
|
+ padding: 0 0 20px 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .btn {
|
|
|
+ text-align: center;
|
|
|
+ margin: 20px 0 0 0;
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|