杨豪
3 years ago
17 changed files with 539 additions and 112 deletions
@ -0,0 +1,20 @@ |
|||||||
|
/* |
||||||
|
* 异步创建script标签
|
||||||
|
*/ |
||||||
|
export default function MapLoader (key) {
|
||||||
|
return new Promise((resolve, reject) => { |
||||||
|
if (window.AMap) { |
||||||
|
resolve(window.AMap) |
||||||
|
} else { |
||||||
|
var script = document.createElement('script') |
||||||
|
script.type = 'text/javascript' |
||||||
|
script.async = true |
||||||
|
script.src = 'https://webapi.amap.com/maps?v=1.4.15&key=6b5ed4e01a6a876cc337c6dd805c2336&plugin=AMap.Autocomplete,AMap.PlaceSearch' |
||||||
|
script.onerror = reject |
||||||
|
document.head.appendChild(script) |
||||||
|
} |
||||||
|
window.initAMap = () => { |
||||||
|
resolve(window.AMap) |
||||||
|
} |
||||||
|
}) |
||||||
|
} |
@ -0,0 +1,275 @@ |
|||||||
|
<template> |
||||||
|
<div class="app-container"> |
||||||
|
<!--工具栏--> |
||||||
|
<div class="head-container"> |
||||||
|
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'--> |
||||||
|
<crudOperation :permission="permission" /> |
||||||
|
<!--表单组件--> |
||||||
|
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="50%"> |
||||||
|
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="120px"> |
||||||
|
<el-form-item label="项目归属" prop="enterpriseId"> |
||||||
|
<el-select v-model="form.enterpriseId" placeholder=""> |
||||||
|
<el-option |
||||||
|
v-for="item in enterprisesList" |
||||||
|
:key="item.id" |
||||||
|
:label="item.enterpriseName" |
||||||
|
:value="item.id"> |
||||||
|
</el-option> |
||||||
|
</el-select> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="项目类型"> |
||||||
|
<el-radio-group v-model="form.resourceType"> |
||||||
|
<el-radio :label="1">供应</el-radio> |
||||||
|
<el-radio :label="2">需求</el-radio> |
||||||
|
</el-radio-group> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="标题" prop="title"> |
||||||
|
<el-input v-model="form.title" style="width: 370px;" /> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="资源类型" prop="resourceCagetoryId"> |
||||||
|
<!-- <el-cascader |
||||||
|
v-model="form.resourceCagetoryId" |
||||||
|
:options="resourceTypeList" |
||||||
|
placeholder="" |
||||||
|
:props="{ checkStrictly: true }" |
||||||
|
:show-all-levels="false"> |
||||||
|
</el-cascader> --> |
||||||
|
<Treeselect |
||||||
|
v-model="form.resourceCagetoryId" |
||||||
|
:options="resourceTypeList" |
||||||
|
style="width: 370px" |
||||||
|
placeholder="选择资源类型"> |
||||||
|
</Treeselect> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="项目展示图片"> |
||||||
|
<MaterialList v-model="form.resourceImgs" style="width: 500px" type="image" :num="4" :width="150" :height="150" /> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="资金需求" prop="capital"> |
||||||
|
<el-input v-model="form.capital" style="width: 370px;" /> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="详细描述" prop="detailedDescription"> |
||||||
|
<el-input |
||||||
|
type="textarea" |
||||||
|
v-model="form.detailedDescription" |
||||||
|
placeholder="" |
||||||
|
style="width: 370px;" |
||||||
|
> |
||||||
|
</el-input> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="展示开始时间" prop="resourceStartTime"> |
||||||
|
<el-date-picker |
||||||
|
v-model="form.resourceStartTime" |
||||||
|
type="date" |
||||||
|
placeholder="选择日期" |
||||||
|
style="width: 370px;"> |
||||||
|
</el-date-picker> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="展示结束时间" prop="resourceEndTime"> |
||||||
|
<el-date-picker |
||||||
|
v-model="form.resourceEndTime" |
||||||
|
type="date" |
||||||
|
placeholder="选择日期" |
||||||
|
style="width: 370px;"> |
||||||
|
</el-date-picker> |
||||||
|
</el-form-item> |
||||||
|
</el-form> |
||||||
|
<div slot="footer" class="dialog-footer"> |
||||||
|
<el-button type="text" @click="crud.cancelCU">取消</el-button> |
||||||
|
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button> |
||||||
|
</div> |
||||||
|
</el-dialog> |
||||||
|
<!--表格渲染--> |
||||||
|
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler"> |
||||||
|
<el-table-column type="selection" width="55" /> |
||||||
|
<el-table-column v-if="columns.visible('id')" prop="id" label="id" /> |
||||||
|
<el-table-column v-if="columns.visible('resourceType')" prop="resourceType" label="项目类型"> |
||||||
|
<template slot-scope="scope"> |
||||||
|
<span>{{scope.row.resourceType == 1? '供应' : '需求' }}</span> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<!-- <el-table-column v-if="columns.visible('createUserId')" prop="createUserId" label="项目归属" /> --> |
||||||
|
<el-table-column v-if="columns.visible('title')" prop="title" label="标题" /> |
||||||
|
<!-- <el-table-column v-if="columns.visible('resourceCagetoryId')" prop="resourceCagetoryId" label="资源类型id" /> --> |
||||||
|
<el-table-column v-if="columns.visible('capital')" prop="capital" label="资金需求" /> |
||||||
|
<el-table-column v-if="columns.visible('detailedDescription')" prop="detailedDescription" label="详细描述" width="200px"> |
||||||
|
<template slot-scope="scope"> |
||||||
|
<el-tooltip class="item" effect="dark" :content="scope.row.detailedDescription" placement="top"> |
||||||
|
<p style="width:100%;overflow:hidden;white-space: nowrap;text-overflow:ellipsis;">{{scope.row.detailedDescription}}</p> |
||||||
|
</el-tooltip> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column v-if="columns.visible('resourceStartTime')" prop="resourceStartTime" label="展示开始时间"> |
||||||
|
<template slot-scope="scope"> |
||||||
|
<span>{{ parseTime(scope.row.resourceStartTime).split(' ')[0] }}</span> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column v-if="columns.visible('resourceEndTime')" prop="resourceEndTime" label="展示结束时间"> |
||||||
|
<template slot-scope="scope"> |
||||||
|
<span>{{ parseTime(scope.row.resourceEndTime).split(' ')[0] }}</span> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column v-if="columns.visible('resourceAuditState')" prop="resourceAuditState" label="资源审核状态"> |
||||||
|
<template slot-scope="scope"> |
||||||
|
<el-tag type="info" v-if="scope.row.resourceAuditState == 0">未提交</el-tag> |
||||||
|
<el-tag v-if="scope.row.resourceAuditState == 1">审核中</el-tag> |
||||||
|
<el-tag type="success" v-if="scope.row.resourceAuditState == 2">审核通过</el-tag> |
||||||
|
<el-tag type="danger" v-if="scope.row.resourceAuditState == 3">审核不通过</el-tag> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column v-if="columns.visible('resourceState')" prop="resourceState" label="资源状态"> |
||||||
|
<template slot-scope="scope"> |
||||||
|
<el-tag type="info" v-if="scope.row.resourceState == 0">未开始</el-tag> |
||||||
|
<el-tag v-if="scope.row.resourceState == 1">展示中</el-tag> |
||||||
|
<el-tag type="success" v-if="scope.row.resourceState == 2">已结束</el-tag> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column v-permission="['admin','Resources:edit','Resources:del']" label="操作" width="150px" align="center"> |
||||||
|
<template slot-scope="scope"> |
||||||
|
<udOperation |
||||||
|
:data="scope.row" |
||||||
|
:permission="permission" |
||||||
|
/> |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
</el-table> |
||||||
|
<!--分页组件--> |
||||||
|
<pagination /> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script> |
||||||
|
import crudResources from '@/api/Resources' |
||||||
|
import crudResourcesCagetory from '@/api/ResourcesCagetory' |
||||||
|
import CRUD, { presenter, header, form, crud } from '@crud/crud' |
||||||
|
import rrOperation from '@crud/RR.operation' |
||||||
|
import crudOperation from '@crud/CRUD.operation' |
||||||
|
import udOperation from '@crud/UD.operation' |
||||||
|
import pagination from '@crud/Pagination' |
||||||
|
import MaterialList from "@/components/material"; |
||||||
|
import MulPicUpload from "@/components/mul-pic-upload"; |
||||||
|
import { initData } from "@/api/data" |
||||||
|
import Treeselect from "@riophae/vue-treeselect"; |
||||||
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css"; |
||||||
|
|
||||||
|
// crud交由presenter持有 |
||||||
|
const defaultCrud = CRUD({ title: '企业资源', url: 'api/Resources', sort: 'id,desc', crudMethod: { ...crudResources }}) |
||||||
|
const defaultForm = { |
||||||
|
resourceType: 1, |
||||||
|
createUserId: null, |
||||||
|
title: null, |
||||||
|
resourceImgs: [], |
||||||
|
enterpriseId: '', |
||||||
|
resourceCagetoryId: null, |
||||||
|
capital: null, |
||||||
|
detailedDescription: null, |
||||||
|
resourceStartTime: null, |
||||||
|
resourceEndTime: null, |
||||||
|
} |
||||||
|
export default { |
||||||
|
name: 'Resources', |
||||||
|
components: { pagination, crudOperation, rrOperation, udOperation ,MaterialList, MulPicUpload, Treeselect}, |
||||||
|
mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()], |
||||||
|
data() { |
||||||
|
return { |
||||||
|
permission: { |
||||||
|
add: ['admin', 'Resources:add'], |
||||||
|
edit: ['admin', 'Resources:edit'], |
||||||
|
del: ['admin', 'Resources:del'] |
||||||
|
}, |
||||||
|
resourceTypeList: [], |
||||||
|
enterprisesList: [], |
||||||
|
rules: { |
||||||
|
title: [ |
||||||
|
{ required: true, message: '请输入项目名称', trigger: 'blur' }, |
||||||
|
], |
||||||
|
enterpriseId:[ |
||||||
|
{ required: true, message: '请选择项目归属'}, |
||||||
|
], |
||||||
|
resourceTypeList: [ |
||||||
|
{ required: true, message: '请选择资源类型'}, |
||||||
|
], |
||||||
|
capital: [ |
||||||
|
{ required: true, message: '请输入资金需求', trigger: 'blur' }, |
||||||
|
], |
||||||
|
detailedDescription: [ |
||||||
|
{ required: true, message: '请输入详情描述', trigger: 'blur' }, |
||||||
|
], |
||||||
|
resourceStartTime: [ |
||||||
|
{ required: true, message: '请输入展示开始时间', trigger: 'blur' }, |
||||||
|
], |
||||||
|
resourceEndTime: [ |
||||||
|
{ required: true, message: '请输入展示结束时间', trigger: 'blur' }, |
||||||
|
], |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
watch: { |
||||||
|
}, |
||||||
|
mounted(){ |
||||||
|
this.getResourcesCagetory() |
||||||
|
this.getEnterprises() |
||||||
|
}, |
||||||
|
methods: { |
||||||
|
//获取项目分类 |
||||||
|
getResourcesCagetory(){ |
||||||
|
initData('/api/ResourcesCagetory',{ |
||||||
|
page: 1, |
||||||
|
size: 100, |
||||||
|
sort: ['id,desc'], |
||||||
|
}).then((res)=>{ |
||||||
|
this.resourceTypeList = this.setChild(res.content) |
||||||
|
console.log(this.resourceTypeList) |
||||||
|
}) |
||||||
|
}, |
||||||
|
setChild(arr){ |
||||||
|
arr.forEach(item=>{ |
||||||
|
item.label = item.cagetoryName |
||||||
|
item.value = item.id |
||||||
|
item.children = item.categoryList |
||||||
|
if(item.categoryList && item.categoryList.length > 0){ |
||||||
|
this.setChild(item.categoryList) |
||||||
|
} |
||||||
|
}) |
||||||
|
return arr |
||||||
|
}, |
||||||
|
//获取公司列表 |
||||||
|
getEnterprises(){ |
||||||
|
initData('/api/Enterprise/listEnterprises',{ |
||||||
|
page: 1, |
||||||
|
size: 100, |
||||||
|
sort: ['id,desc'], |
||||||
|
}).then((res)=>{ |
||||||
|
console.log(res) |
||||||
|
this.enterprisesList = res |
||||||
|
}) |
||||||
|
}, |
||||||
|
|
||||||
|
// 获取数据前设置好接口地址 |
||||||
|
[CRUD.HOOK.beforeRefresh]() { |
||||||
|
return true |
||||||
|
}, // 新增与编辑前做的操作 |
||||||
|
[CRUD.HOOK.afterToCU](crud, form) { |
||||||
|
}, |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</script> |
||||||
|
|
||||||
|
<style scoped> |
||||||
|
.table-img { |
||||||
|
display: inline-block; |
||||||
|
text-align: center; |
||||||
|
background: #ccc; |
||||||
|
color: #fff; |
||||||
|
white-space: nowrap; |
||||||
|
position: relative; |
||||||
|
overflow: hidden; |
||||||
|
vertical-align: middle; |
||||||
|
width: 32px; |
||||||
|
height: 32px; |
||||||
|
line-height: 32px; |
||||||
|
} |
||||||
|
</style> |
Loading…
Reference in new issue