426 lines
21 KiB
HTML
426 lines
21 KiB
HTML
<!--#
|
|
layout("/layouts/platform.html"){
|
|
#-->
|
|
<div id="app" v-cloak>
|
|
<guava ref="guava">
|
|
<template>
|
|
<el-card shadow="never">
|
|
<div class="search">
|
|
<div class="search-item">
|
|
<div class="search-item-label">年  度:</div>
|
|
<div class="search-item-option">
|
|
<el-date-picker
|
|
v-model="pageForm.year"
|
|
type="year"
|
|
style="width: 100%"
|
|
@change="doSearch"
|
|
value-format="yyyy"
|
|
placeholder="请选择">
|
|
</el-date-picker>
|
|
</div>
|
|
</div>
|
|
<div class="search-item">
|
|
<div class="search-item-label">项目名称:</div>
|
|
<div class="search-item-option">
|
|
<el-input placeholder="请输入内容" clearable v-model="pageForm.projectName"
|
|
@keyup.enter.native="doSearch" style="width:100%"></el-input>
|
|
</div>
|
|
</div>
|
|
<div class="search-query">
|
|
<el-button type="primary" icon="el-icon-search" @click="doSearch">搜索
|
|
</el-button>
|
|
</div>
|
|
</div>
|
|
</el-card>
|
|
|
|
<el-card shadow="never" class="mt10">
|
|
<table-tool label="惠民项目" :app="this">
|
|
<template #func>
|
|
<el-button type="primary" size="small" icon="el-icon-plus"
|
|
@click="openAdd">新建惠民项目</el-button>
|
|
</template>
|
|
</table-tool>
|
|
<el-table :data="tableData" style="width: 100%" row-key="id"
|
|
@sort-change="pageOrder" :size="tableSize"
|
|
v-loading="tableLoading" ref="table" class="vi-table">
|
|
<el-table-column align="center" header-align="center" type="index"
|
|
:index="indexMethod" label="序号"
|
|
width="80px"></el-table-column>
|
|
<el-table-column
|
|
align="center"
|
|
header-align="center"
|
|
v-for="column in tableColumns"
|
|
show-overflow-tooltip
|
|
:sortable="column.sortable"
|
|
:label="column.label"
|
|
:prop="column.prop" :width="column.width" min-width="100px">
|
|
</el-table-column>
|
|
<el-table-column prop="userOnline" align="center" header-align="center"
|
|
label="操作" width="300px">
|
|
<template scope="{row}">
|
|
<el-button size="mini" :loading="row.loading" @click="openView(row)">查看</el-button>
|
|
<el-button size="mini" :loading="row.loading" type="primary" @click="openEdit(row)">编辑</el-button>
|
|
<el-button size="mini" :loading="row.loading" type="danger" @click="doDelete(row.id)">删除</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<!--#include("/layouts/pagination.html"){}#-->
|
|
</el-card>
|
|
</template>
|
|
|
|
<template #edit>
|
|
<el-form :model="formData" ref="form" :rules="formRules" label-width="120px"
|
|
v-loading="formLoading">
|
|
<vi-title title="惠民项目信息"></vi-title>
|
|
|
|
<el-form-item prop="name" label="项目名称">
|
|
<el-input v-model="formData.projectName" placeholder="项目名称" maxlength="100"></el-input>
|
|
</el-form-item>
|
|
<el-row>
|
|
<!--<el-col span="12">
|
|
<el-form-item prop="createTime" label="创建时间">
|
|
<el-date-picker
|
|
v-model="formData.createTime"
|
|
type="datetime"
|
|
placeholder="选择日期时间">
|
|
</el-date-picker>
|
|
</el-form-item>
|
|
</el-col>-->
|
|
<el-col span="24">
|
|
<el-form-item label="货物列表" prop="benefitingExhibits">
|
|
<el-card class="item" shadow="hover">
|
|
<div class="s-options-list" style="margin-top: 10px;">
|
|
<el-table :data="formData.benefitingExhibits" border>
|
|
<el-table-column
|
|
align="center"
|
|
header-align="center"
|
|
label="排序编号">
|
|
<template slot-scope="{row}">
|
|
<el-input v-model="row.sortNum" autosize
|
|
class="text-input" clearable
|
|
data-type="option"
|
|
></el-input>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column
|
|
align="center"
|
|
header-align="center"
|
|
label="货物名称">
|
|
<template slot-scope="{row}">
|
|
|
|
<el-input v-model="row.goodsName" autosize
|
|
class="text-input" clearable
|
|
data-type="option"
|
|
></el-input>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column
|
|
align="center"
|
|
header-align="center"
|
|
label="货物价格">
|
|
<template slot-scope="{row}">
|
|
<el-input v-model="row.goodsPrice" autosize
|
|
class="text-input" clearable
|
|
data-type="option"
|
|
></el-input>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column
|
|
align="center"
|
|
header-align="center"
|
|
label="货物类别">
|
|
<template slot-scope="{row}">
|
|
<el-select filterable clearable v-model="row.typeId"
|
|
placeholder="请选择类别">
|
|
<el-option v-for="item in typeList"
|
|
:key="item.id"
|
|
:label="item.typeName"
|
|
:value="item.id"
|
|
></el-option>
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column
|
|
align="center"
|
|
header-align="center"
|
|
label="厂商">
|
|
<template slot-scope="{row}">
|
|
<el-input v-model="row.manufacturer" autosize
|
|
class="text-input" clearable
|
|
data-type="option"
|
|
></el-input>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column
|
|
align="center"
|
|
header-align="center"
|
|
label="图片" width="130px">
|
|
<template slot-scope="{row,$index}">
|
|
<image-Upload ref="imageUpload" :height="100"
|
|
:width="100" :limit="1"
|
|
:file-type="['png','jpg']"
|
|
:file-size="10"
|
|
v-model="row.imgUrl"></image-Upload>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column align="center"
|
|
header-align="center"
|
|
label="详情">
|
|
<template slot-scope="{row,$index}">
|
|
<el-link type="primary"
|
|
@click="openDescRichText(row.description,$index)">
|
|
货物详情
|
|
</el-link>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column
|
|
align="center"
|
|
header-align="center"
|
|
label="操作"
|
|
width="100px">
|
|
<template slot-scope="{row,$index}">
|
|
<div class="option-delete">
|
|
<el-button circle
|
|
icon="el-icon-delete"
|
|
size="mini" type="danger"
|
|
@click="deleteRow(row,$index)"></el-button>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
|
|
<div class="s-operation">
|
|
<el-button size="small" type="primary"
|
|
@click="formData.benefitingExhibits.push({goodsId:'',goodsName:'货物'+(formData.benefitingExhibits.length+1),sortNum:formData.benefitingExhibits.length+1,imgUrl:null})">
|
|
添加货物
|
|
</el-button>
|
|
</div>
|
|
</div>
|
|
</el-card>
|
|
|
|
</el-form-item>
|
|
<el-form-item label="项目封面" prop="cover">
|
|
<image-Upload ref="imageUpload" :height="200"
|
|
:width="200" :limit="1"
|
|
:file-type="['png','jpg']"
|
|
:file-size="10"
|
|
v-model="formData.cover"></image-Upload>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
</el-form>
|
|
<el-button @click="doAdd" type="primary" style="float: right">
|
|
提交
|
|
</el-button>
|
|
</template>
|
|
|
|
|
|
<template #view>
|
|
<el-descriptions :column="6" border class="table_fixed">
|
|
<el-descriptions-item :span="3" label="项目名称">
|
|
{{viewData.projectName}}
|
|
</el-descriptions-item>
|
|
<el-descriptions-item :span="3" label="选择时间">
|
|
{{viewData.createTime}}
|
|
</el-descriptions-item>
|
|
<template v-for="i in viewData.benefitingExhibits">
|
|
<el-descriptions-item label="货物名称">
|
|
{{i.goodsName}}
|
|
</el-descriptions-item>
|
|
<el-descriptions-item label="货物价格">
|
|
{{i.goodsPrice}}
|
|
</el-descriptions-item>
|
|
<el-descriptions-item label="货物类别">
|
|
{{i.typeId}}
|
|
</el-descriptions-item>
|
|
<el-descriptions-item label="厂商">
|
|
{{i.manufacturer}}
|
|
</el-descriptions-item>
|
|
<el-descriptions-item label="货物详情">
|
|
<span v-html="i.description"></span>
|
|
</el-descriptions-item>
|
|
<el-descriptions-item label="货物图片">
|
|
<el-image
|
|
:src="CREATE_PREVIEW_URL(i.imgUrl)"
|
|
@click="preview(i.imgUrl,i.imgUrl)"
|
|
fit="cover"
|
|
v-if="i.imgUrl"
|
|
style="width: 100px; height: 100px;"></el-image>
|
|
<div v-else>暂无</div>
|
|
</el-descriptions-item>
|
|
</template>
|
|
|
|
</el-descriptions>
|
|
</template>
|
|
|
|
</guava>
|
|
|
|
<el-dialog
|
|
:close-on-click-modal="false"
|
|
:visible.sync="richTextDialog"
|
|
title="货物详情"
|
|
:append-to-body="true"
|
|
width="60%">
|
|
<div id="descRichText">
|
|
</div>
|
|
<span slot="footer" class="dialog-footer">
|
|
<el-button @click="richTextDialog = false">取 消</el-button>
|
|
<el-button type="primary" @click="getRichText">确 定</el-button>
|
|
</span>
|
|
</el-dialog>
|
|
</div>
|
|
<script>
|
|
var vue = new Vue({
|
|
el: '#app',
|
|
mixins: [initTableMixins],
|
|
data() {
|
|
return{
|
|
pageForm:{
|
|
year:moment().format('YYYY'),
|
|
},
|
|
tableColumns:[
|
|
{prop: 'year', label: '年度'},
|
|
{prop: 'projectName', label: '项目名称'},
|
|
{prop: 'createTime', label: '创建时间'},
|
|
],
|
|
formData:{
|
|
benefitingExhibits:[],
|
|
},
|
|
typeList:[],
|
|
subjectIndex: null,
|
|
richTextDialog: false,
|
|
deleteRowIds: [],
|
|
formRules: {
|
|
projectName: [{required: true, message: '必填', trigger: ['blur', 'change']}],
|
|
cover: [{required: true, message: '必填', trigger: ['blur', 'change']}],
|
|
benefitingExhibits: [{
|
|
required: true,
|
|
message: '必填',
|
|
trigger: ['blur', 'change']
|
|
}],
|
|
},
|
|
viewData:{},
|
|
}
|
|
},
|
|
methods:{
|
|
openAdd(){
|
|
this.formData = {
|
|
projectName: null,
|
|
createdTime: null,
|
|
benefitingExhibits: [
|
|
{
|
|
goodsName: '货物1',
|
|
goodsId: '',
|
|
typeId: '',
|
|
goodsPrice: '',
|
|
manufacturer: '',
|
|
sortNum: '1',
|
|
imgUrl: ''
|
|
}
|
|
]
|
|
}
|
|
if (this.$refs.form) this.$refs.form.resetFields();
|
|
this.$refs.guava.edit()
|
|
},
|
|
async openEdit(row) {
|
|
this.formData = await this.findOne(row.id)
|
|
this.$refs.guava.edit()
|
|
},
|
|
async openView(row) {
|
|
this.viewData = await this.findOne(row.id)
|
|
const self = this;
|
|
this.viewData.benefitingExhibits.forEach(v=>{
|
|
const obj = self.typeList.find(o => o.id=v.typeId)
|
|
v.typeId = obj.typeName;
|
|
})
|
|
this.$refs.guava.view()
|
|
},
|
|
async findOne(id) {
|
|
const resp = await $.post(loc() + "/findOne", {id: id})
|
|
if (resp.code === 0) {
|
|
return resp.data
|
|
} else {
|
|
this.notifyError("查询失败")
|
|
}
|
|
},
|
|
async doDelete(id) {
|
|
const confirm = await this.$confirm('确定要删除该项目吗?', '提示', {type: 'warning'})
|
|
if (confirm) {
|
|
const resp = await $.post(loc() + "/doDelete", {id})
|
|
if (resp.code === 0) {
|
|
this.pageData()
|
|
this.notifySuccess(resp.msg)
|
|
} else {
|
|
this.notifyWarning(resp.msg)
|
|
}
|
|
}
|
|
},
|
|
async doAdd(){
|
|
const formValid = await this.$refs["form"].validate()
|
|
if (formValid) {
|
|
const loading = this.$loading({
|
|
lock: true,
|
|
text: '数据保存中请稍后',
|
|
spinner: 'el-icon-loading',
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|
});
|
|
const formData = clone(this.formData)
|
|
formData.benefitingExhibits = JSON.stringify(this.formData.benefitingExhibits)
|
|
formData.deleteRowIds = JSON.stringify(this.deleteRowIds)
|
|
const resp = await $.post(loc() + "/doAdd", formData)
|
|
loading.close()
|
|
if (resp.code === 0) {
|
|
this.pageData()
|
|
this.$refs.guava.index()
|
|
this.deleteRowIds = []
|
|
this.notifySuccess(resp.msg)
|
|
} else {
|
|
this.notifyWarning(resp.msg)
|
|
}
|
|
}
|
|
},
|
|
deleteRow(row, index) {
|
|
this.formData.benefitingExhibits.splice(index, 1)
|
|
if (row.id) this.deleteRowIds.push(row.id)
|
|
},
|
|
openDescRichText(richText, sIdx) {
|
|
this.richTextDialog = true
|
|
this.subjectIndex = sIdx
|
|
this.$nextTick(() => {
|
|
$("#descRichText").html("")
|
|
descRichTextEditor = new wangEditor("#descRichText")
|
|
descRichTextEditor.config.onchange = (html) => {
|
|
richText = (html ? html : "")
|
|
}
|
|
descRichTextEditor.config.uploadImgShowBase64 = true
|
|
descRichTextEditor.create()
|
|
if (richText) {
|
|
descRichTextEditor.txt.html(richText)
|
|
}
|
|
})
|
|
},
|
|
getRichText() {
|
|
this.formData.benefitingExhibits[this.subjectIndex].description = descRichTextEditor.txt.html()
|
|
this.richTextDialog = false
|
|
},
|
|
async getAllType(){
|
|
const resp = await $.get('/platform/benefiting/type/findAllType')
|
|
if (resp.code === 0){
|
|
this.typeList = resp.data;
|
|
}
|
|
},
|
|
},
|
|
async created(){
|
|
this.pageData();
|
|
await this.getAllType();
|
|
},
|
|
});
|
|
</script>
|
|
<!--#
|
|
}
|
|
#-->
|