|
|
@@ -0,0 +1,283 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <el-button size="small" :type="disabled?'':'primary'" @click="editBtn(dialogFormVisible = true)" :disabled="disabled">编 辑</el-button>
|
|
|
+ <el-drawer
|
|
|
+ title="编辑案例"
|
|
|
+ :visible.sync="dialogFormVisible"
|
|
|
+ size="60%"
|
|
|
+ direction="rtl"
|
|
|
+ append-to-body
|
|
|
+ :show-close="false"
|
|
|
+ @close="onCancel">
|
|
|
+ <div class="drawer__panel" >
|
|
|
+ <el-row :gutter="10">
|
|
|
+ <el-form :model="form" :rules="rules" ref="form" size="mini" label-position="top">
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="标题" prop="title">
|
|
|
+ <el-input v-model="form.title" placeholder="请输入标题"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="状态" prop="status">
|
|
|
+ <el-radio-group v-model="form.status" >
|
|
|
+ <el-radio label="新建">新建</el-radio>
|
|
|
+ <el-radio label="发布">发布</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="排序" prop="sequence">
|
|
|
+ <el-input v-model="form.sequence" placeholder="请输入排序"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="封面" prop="cover">
|
|
|
+ <previewImage v-if="form.cover" style="width:256px" :image="form.image" :deletebtn="true"
|
|
|
+ @onSuccess="clearCover"></previewImage>
|
|
|
+ <upload v-else btntype="image" :folderid="folderid" accept=".JPG,.PNG"
|
|
|
+ :bindData="{ ownertable: 'sat_sharematerial', ownerid: form.sat_sharematerialid, usetype: 'cover' }"
|
|
|
+ @onSuccess="onCoverSubmit"></upload>
|
|
|
+ <p class="info">注:建议上传图片大小130x80像素,大小不超过2M,格式为JPG/PNG</p>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="内容" prop="notes">
|
|
|
+ <myEditor ref="editor" :content="form.content" :id="form.sat_sharematerialid"></myEditor>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-form>
|
|
|
+ </el-row>
|
|
|
+ <div>
|
|
|
+ <div style="font-size: 16px;font-weight: bold;margin-bottom: 10px">关联产品</div>
|
|
|
+ <addProduct :sat_sharematerialid="form.sat_sharematerialid" style="margin-bottom: 10px" @selectData="selectData"></addProduct>
|
|
|
+ <tableNewLayout ref="tableRef" :checkbox="false" :custom="true" :data="list" :layout="tablecols"
|
|
|
+ :opwidth="200" :width="true" height="300px">
|
|
|
+ <template v-slot:customcol="scope">
|
|
|
+ <div v-if="scope.column.columnname === 'itemclassfullname'">
|
|
|
+ {{scope.column.data.itemclass?scope.column.data.itemclass.length>0?scope.column.data.itemclass[0].itemclassfullname:'':''}}
|
|
|
+ </div>
|
|
|
+ <p v-else>{{scope.column.data[scope.column.columnname]}}</p>
|
|
|
+ </template>
|
|
|
+ <template v-slot:opreation="scope">
|
|
|
+ <el-button type="text" @click="delClick(scope.data)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </tableNewLayout>
|
|
|
+ <div class="container normal-panel" style="text-align:right">
|
|
|
+ <el-pagination
|
|
|
+ background
|
|
|
+ @size-change="handleSizeChange"
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ :current-page="currentPage"
|
|
|
+ :page-sizes="[20, 50, 100, 200]"
|
|
|
+ :page-size="20"
|
|
|
+ layout="total,sizes, prev, pager, next, jumper"
|
|
|
+ :total="total">
|
|
|
+ </el-pagination>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="fixed__btn__panel">
|
|
|
+ <el-button size="small" type="primary" @click="onCancel" plain class="normal-btn-width" >取 消</el-button>
|
|
|
+ <el-button size="small" @click="onSubmit" class="normal-btn-width">确 定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-drawer>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import upload from '@/components/upload/hw_obs_upload.vue'
|
|
|
+import previewImage from '@/components/previewImage/index.vue'
|
|
|
+import myEditor from '@/components/my-editor/Editor.vue'
|
|
|
+import tableNewLayout from '@/components/dynamic-newTable/index2'
|
|
|
+import addProduct from '@/WebsiteManagement/caseManage/modules/addProduct'
|
|
|
+export default {
|
|
|
+ name: "edit",
|
|
|
+ components:{upload,previewImage,myEditor,tableNewLayout,addProduct},
|
|
|
+ props:['sat_sharematerialid','disabled'],
|
|
|
+ data(){
|
|
|
+ return {
|
|
|
+ dialogFormVisible:false,
|
|
|
+ tablecols:[],
|
|
|
+ list:[],
|
|
|
+ currentPage:0,
|
|
|
+ total:0,
|
|
|
+ form:{
|
|
|
+ "title": "",
|
|
|
+ "notes": "",
|
|
|
+ "content": "",
|
|
|
+ "sat_sharematerialid":0,
|
|
|
+ "status":"新建",
|
|
|
+ "sequence":'',
|
|
|
+ "image":'',
|
|
|
+ "cover":''
|
|
|
+ },
|
|
|
+ rules:{
|
|
|
+ title: [
|
|
|
+ { required: true, message: '请输入标题名称', trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ cover: [
|
|
|
+ { required: true, message: '请上传封面', trigger: 'change' }
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ folderid: JSON.parse(sessionStorage.getItem('folderid')).appfolderid,
|
|
|
+ attinfo_attachment:[],
|
|
|
+ productParam:{
|
|
|
+ "id": "20240801134003",
|
|
|
+ "content": {
|
|
|
+ "sat_sharematerialid": '',
|
|
|
+ "pageNumber":1,
|
|
|
+ "pageSize":20,
|
|
|
+ "where": {
|
|
|
+ "condition": ""
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods:{
|
|
|
+ editBtn(){
|
|
|
+ this.detailInfo()
|
|
|
+ },
|
|
|
+ async detailInfo(){
|
|
|
+ const res = await this.$api.requested({
|
|
|
+ "id":20240801133703,
|
|
|
+ "content": {
|
|
|
+ "sat_sharematerialid":this.sat_sharematerialid
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (res.code == 0){
|
|
|
+ this.tool.showMessage(res,()=>{})
|
|
|
+ }else {
|
|
|
+ this.form = Object.assign({},this.form,res.data)
|
|
|
+ this.$refs.editor.html = res.data.content
|
|
|
+ this.queryFileLink()
|
|
|
+ this.productParam.content.sat_sharematerialid = res.data.sat_sharematerialid
|
|
|
+ this.productData(this.productParam.content.pageNumber = 1)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 获取封面信息
|
|
|
+ async queryFileLink() {
|
|
|
+ this.dialogEditVisible = true
|
|
|
+ const res = await this.$api.requested({
|
|
|
+ "classname": "system.attachment.Attachment",
|
|
|
+ "method": "queryFileLink",
|
|
|
+ "content": {
|
|
|
+ "ownertable": 'sat_sharematerial',
|
|
|
+ "ownerid": this.form.sat_sharematerialid,
|
|
|
+ "usetype": 'cover'//传空返回有所
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.form.image = res.data[0]
|
|
|
+ this.form.cover = res.data[0].url
|
|
|
+ /*res.data[0] ? this.image = res.data[0].url : this.image = { url: '' }*/
|
|
|
+ },
|
|
|
+ onSubmit(){
|
|
|
+ this.$refs.form.validate(async (valid)=>{
|
|
|
+ if (!valid) return false
|
|
|
+ this.form.content = this.$refs.editor.html
|
|
|
+ const res = await this.$api.requested({
|
|
|
+ "id": "20240801133403",
|
|
|
+ "content": this.form
|
|
|
+ })
|
|
|
+ this.tool.showMessage(res,()=>{
|
|
|
+ this.dialogFormVisible = false
|
|
|
+ this.$refs.form.resetFields()
|
|
|
+ this.$refs.editor.html = ''
|
|
|
+ this.form.image = ''
|
|
|
+ this.form.cover = ''
|
|
|
+ this.form.sat_sharematerialid = 0
|
|
|
+ this.$emit('editSuccess')
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async onCancel(){
|
|
|
+ this.dialogFormVisible = false
|
|
|
+ this.$refs.form.resetFields()
|
|
|
+ this.$refs.editor.html = ''
|
|
|
+ this.form.image = ''
|
|
|
+ this.form.cover = ''
|
|
|
+ this.form.sat_sharematerialid = 0
|
|
|
+ this.$emit('onSuccess')
|
|
|
+ },
|
|
|
+ clearCover() {
|
|
|
+ this.form.cover = null
|
|
|
+ this.image = {}
|
|
|
+ },
|
|
|
+ async productData(){
|
|
|
+ const res = await this.$api.requested(this.productParam)
|
|
|
+ this.list = res.data
|
|
|
+ this.total = res.total
|
|
|
+ this.currentPage = res.pageNumber
|
|
|
+ },
|
|
|
+ async onCoverSubmit(data) {
|
|
|
+ const res = await this.$api.requested({
|
|
|
+ "classname": "system.attachment.Attachment",
|
|
|
+ "method": "queryFileLink",
|
|
|
+ "content": {
|
|
|
+ "ownertable": 'sat_sharematerial',
|
|
|
+ "ownerid": this.form.sat_sharematerialid,
|
|
|
+ "usetype": 'cover'//传空返回有所
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.form.cover = res.data[0].url
|
|
|
+ this.form.image = res.data[0]
|
|
|
+ },
|
|
|
+ async selectData(data){
|
|
|
+ const res = await this.$api.requested({
|
|
|
+ "id": "20240801133803",
|
|
|
+ "content": {
|
|
|
+ "sat_sharematerialid": this.form.sat_sharematerialid,
|
|
|
+ "sat_sharematerial_itemsid": data.sat_sharematerial_itemsid,
|
|
|
+ "itemid": data.itemid
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.productParam.content.sat_sharematerialid = this.form.sat_sharematerialid
|
|
|
+ this.productData()
|
|
|
+ },
|
|
|
+ handleSizeChange(val) {
|
|
|
+ // console.log(`每页 ${val} 条`);
|
|
|
+ this.productParam.content.pageSize = val
|
|
|
+ this.productData()
|
|
|
+ },
|
|
|
+ handleCurrentChange(val) {
|
|
|
+ // console.log(`当前页: ${val}`);
|
|
|
+ this.productParam.content.pageNumber = val
|
|
|
+ this.productData()
|
|
|
+ },
|
|
|
+ delClick(data){
|
|
|
+ this.$confirm('确定删除该商品吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then( () => {
|
|
|
+ this.delSuccess(data)
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message({
|
|
|
+ type: 'info',
|
|
|
+ message: '已取消删除'
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ async delSuccess(data){
|
|
|
+ const res = await this.$api.requested({
|
|
|
+ "id":20240801133903,
|
|
|
+ "content": {
|
|
|
+ "sat_sharematerial_itemsid":data.sat_sharematerial_itemsid
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.tool.showMessage(res,()=>{
|
|
|
+ this.productData()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.tablecols = this.tool.tabelCol(this.$route.name).productTable.tablecols
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+
|
|
|
+</style>
|