|
@@ -1,166 +1,210 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
+ <div>
|
|
|
|
|
|
- <el-card class="box-card">
|
|
|
- <template #header>
|
|
|
- <div class="card-header">
|
|
|
- <span>产品详情</span>
|
|
|
- <el-button size="mini" style="float:right" @click="router.go(-1)">返回</el-button>
|
|
|
- <el-button size="mini" style="float:right" type="primary" @click="updateProduct">修改</el-button>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <el-form>
|
|
|
- <el-form-item label="标题:">
|
|
|
- <el-input v-model="productDetail.title"></el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="图片:">
|
|
|
- <el-image v-model="productDetail.url" style="width: 100px; height: 100px; margin-right: 10px"
|
|
|
- fit="cover"></el-image>
|
|
|
- <el-upload :http-request="httpRequests" multiple :show-file-list="true" list-type="picture-card">
|
|
|
- <el-icon>
|
|
|
- <Plus />
|
|
|
- </el-icon>
|
|
|
- </el-upload>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="简介:">
|
|
|
- <el-input v-model="productDetail.synopsis"></el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="详情:">
|
|
|
- <el-image v-model="productDetail.detail" style="width: 100px; height: 100px; margin-right: 10px"
|
|
|
- fit="cover"></el-image>
|
|
|
- <el-upload :http-request="detailhttpRequests" multiple :show-file-list="true"
|
|
|
- list-type="picture-card">
|
|
|
- <el-icon>
|
|
|
- <Plus />
|
|
|
- </el-icon>
|
|
|
- </el-upload>
|
|
|
- <!-- <EditorWithBinding v-model="productDetail.detail"></EditorWithBinding> -->
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="产品介绍:">
|
|
|
- <EditorWithBinding v-model="productDetail.product_introduction"></EditorWithBinding>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="技术参数:">
|
|
|
- <EditorWithBinding v-model="productDetail.technical_parameters"></EditorWithBinding>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="使用说明:">
|
|
|
- <EditorWithBinding v-model="productDetail.instructions"></EditorWithBinding>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="支持软件:">
|
|
|
- <el-upload :http-request="httpRequest" class="upload-demo" drag
|
|
|
- action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15" multiple>
|
|
|
- <el-icon class="el-icon--upload">
|
|
|
- <upload-filled />
|
|
|
- </el-icon>
|
|
|
- <div class="el-upload__text" style="width: 300px">
|
|
|
- 选择上传文件
|
|
|
- </div>
|
|
|
- </el-upload>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="可选配件:">
|
|
|
- <EditorWithBinding v-model="productDetail.optional_accessories"></EditorWithBinding>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- </el-card>
|
|
|
- </div>
|
|
|
+ <el-card class="box-card">
|
|
|
+ <template #header>
|
|
|
+ <div class="card-header">
|
|
|
+ <span>产品详情</span>
|
|
|
+ <el-button size="default" style="float:right" @click="router.go(-1)">返回</el-button>
|
|
|
+ <el-button size="default" style="float:right" type="primary" @click="updateProduct">修改</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <el-form>
|
|
|
+ <el-form-item label="标题:">
|
|
|
+ <el-input v-model="productDetail.title"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="产品/服务:">
|
|
|
+ <el-select v-model="productDetail.type" placeholder="请选择添加类型">
|
|
|
+ <el-option label="服务" value="serve"/>
|
|
|
+ <el-option label="产品" value="product"/>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="产品类型:">
|
|
|
+ <el-select v-model="productDetail.ptype" :disabled="productDetail.type === 'serve'"
|
|
|
+ placeholder="请选择产品类型" style="width: 20vw">
|
|
|
+ <el-option v-for="p in productType " :value="p.name" :label="p.name" :key="p.ID"/>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="是否首页展示:">
|
|
|
+ <el-select v-model="productDetail.isIndex" placeholder="请选择是否首页显示" style="width: 20vw">
|
|
|
+ <el-option label="是" value="true"/>
|
|
|
+ <el-option label="否" value="false"/>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="图片:">
|
|
|
+ <el-image :src="productDetail.url" style="width: 100px; height: 100px; margin-right: 10px"
|
|
|
+ fit="cover"></el-image>
|
|
|
+ <el-upload :http-request="httpRequests" multiple :show-file-list="true" list-type="picture-card">
|
|
|
+ <el-icon>
|
|
|
+ <Plus/>
|
|
|
+ </el-icon>
|
|
|
+ </el-upload>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="简介:">
|
|
|
+ <el-input v-model="productDetail.synopsis"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="详情:">
|
|
|
+ <el-image :src="productDetail.detail" style="width: 100px; height: 100px; margin-right: 10px"
|
|
|
+ fit="cover"></el-image>
|
|
|
+ <el-upload :http-request="detailhttpRequests" multiple :show-file-list="true"
|
|
|
+ list-type="picture-card">
|
|
|
+ <el-icon>
|
|
|
+ <Plus/>
|
|
|
+ </el-icon>
|
|
|
+ </el-upload>
|
|
|
+ <!-- <EditorWithBinding v-model="productDetail.detail"></EditorWithBinding> -->
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="产品介绍:">
|
|
|
+ <EditorWithBinding v-model="productDetail.product_introduction"></EditorWithBinding>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="技术参数:">
|
|
|
+ <EditorWithBinding v-model="productDetail.technical_parameters"></EditorWithBinding>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="使用说明:">
|
|
|
+ <EditorWithBinding v-model="productDetail.instructions"></EditorWithBinding>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="支持软件:">
|
|
|
+ <el-upload :http-request="httpRequest" class="upload-demo" drag
|
|
|
+ action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15" multiple>
|
|
|
+ <el-icon class="el-icon--upload">
|
|
|
+ <upload-filled/>
|
|
|
+ </el-icon>
|
|
|
+ <div class="el-upload__text" style="width: 300px">
|
|
|
+ 选择上传文件
|
|
|
+ </div>
|
|
|
+ </el-upload>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="可选配件:">
|
|
|
+ <EditorWithBinding v-model="productDetail.optional_accessories"></EditorWithBinding>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </el-card>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { onBeforeMount, reactive, ref } from 'vue';
|
|
|
-import { useRoute, useRouter } from 'vue-router'
|
|
|
+import {onBeforeMount, reactive, ref} from 'vue';
|
|
|
+import {useRoute, useRouter} from 'vue-router'
|
|
|
import product from "../../api/product.js";
|
|
|
-import { ElMessage } from "element-plus";
|
|
|
+import {ElMessage} from "element-plus";
|
|
|
import EditorWithBinding from "../EditorWithBinding.vue";
|
|
|
import resource from "../../api/resource.js";
|
|
|
|
|
|
const route = useRoute();
|
|
|
const router = useRouter();
|
|
|
const productDetail = reactive({
|
|
|
- id: '',
|
|
|
- title: '',
|
|
|
- synopsis: '',
|
|
|
- detail: '',
|
|
|
- url: '',
|
|
|
- product_introduction: '',
|
|
|
- technical_parameters: '',
|
|
|
- instructions: '',
|
|
|
- supporting_software: '',
|
|
|
- optional_accessories: '',
|
|
|
+ id: '',
|
|
|
+ title: '',
|
|
|
+ type: '',
|
|
|
+ ptype: '',
|
|
|
+ isIndex: '',
|
|
|
+ synopsis: '',
|
|
|
+ detail: '',
|
|
|
+ url: '',
|
|
|
+ product_introduction: '',
|
|
|
+ technical_parameters: '',
|
|
|
+ instructions: '',
|
|
|
+ supporting_software: '',
|
|
|
+ optional_accessories: '',
|
|
|
})
|
|
|
//定义一个响应式数组用来接收图片
|
|
|
const fileList = ref([])
|
|
|
const fileLists = ref([])
|
|
|
const detailfileLists = ref([])
|
|
|
+const productType = ref([])
|
|
|
|
|
|
//自定义函数用来覆盖原有的XHR行为(默认提交行为)
|
|
|
function detailhttpRequests(option) {
|
|
|
- //将图片存到数组中
|
|
|
- detailfileLists.value.push(option)
|
|
|
+ //将图片存到数组中
|
|
|
+ detailfileLists.value.push(option)
|
|
|
}
|
|
|
+
|
|
|
//自定义函数用来覆盖原有的XHR行为(默认提交行为)
|
|
|
function httpRequest(option) {
|
|
|
- //将图片存到数组中
|
|
|
- fileList.value.push(option)
|
|
|
+ //将图片存到数组中
|
|
|
+ fileList.value.push(option)
|
|
|
}
|
|
|
+
|
|
|
function httpRequests(option) {
|
|
|
- //将图片存到数组中
|
|
|
- fileLists.value.push(option)
|
|
|
+ //将图片存到数组中
|
|
|
+ fileLists.value.push(option)
|
|
|
+}
|
|
|
+
|
|
|
+//产品类型
|
|
|
+function getProductType() {
|
|
|
+ product.getProductType().then(res => {
|
|
|
+ if (res.data.Code === 200) {
|
|
|
+ productType.value = res.data.Data
|
|
|
+ console.log(productType)
|
|
|
+ } else {
|
|
|
+ ElMessage.error(res.data.Msg)
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
-const handleContentChange = (htmlContent) => {
|
|
|
- productDetail.detail = htmlContent
|
|
|
- // 在这里可以使用接收到的内容进行进一步处理或者存储等操作
|
|
|
-};
|
|
|
+
|
|
|
const updateProduct = async () => {
|
|
|
- let dataForm = new FormData();
|
|
|
- dataForm.append('types', "files")
|
|
|
- //将图片的二进制通过表单的形式发送到后台
|
|
|
- fileList.value.forEach((it, index) => {
|
|
|
- dataForm.append('file', it.file)
|
|
|
- })
|
|
|
- const files = await product.uploadFile(dataForm)
|
|
|
+ let dataForm = new FormData();
|
|
|
+ dataForm.append('types', "files")
|
|
|
+ //将图片的二进制通过表单的形式发送到后台
|
|
|
+ fileList.value.forEach((it, index) => {
|
|
|
+ dataForm.append('file', it.file)
|
|
|
+ })
|
|
|
+ const files = await product.uploadFile(dataForm)
|
|
|
+ if (files.data.Code === 200) {
|
|
|
productDetail.supporting_software = files.data.Data
|
|
|
+ }
|
|
|
|
|
|
- //详情图开始
|
|
|
- let detaildataForms = new FormData();
|
|
|
- detaildataForms.append('types', "serve")
|
|
|
- //将图片的二进制通过表单的形式发送到后台
|
|
|
- detailfileLists.value.forEach((it, index) => {
|
|
|
- detaildataForms.append('file', it.file)
|
|
|
- })
|
|
|
- const detailfileRes = await product.uploadFile(detaildataForms)
|
|
|
+ //详情图开始
|
|
|
+ let detaildataForms = new FormData();
|
|
|
+ detaildataForms.append('types', "serve")
|
|
|
+ //将图片的二进制通过表单的形式发送到后台
|
|
|
+ detailfileLists.value.forEach((it, index) => {
|
|
|
+ detaildataForms.append('file', it.file)
|
|
|
+ })
|
|
|
+ const detailfileRes = await product.uploadFile(detaildataForms)
|
|
|
+ if (detailfileRes.data.Code === 200) {
|
|
|
productDetail.detail = detailfileRes.data.Data
|
|
|
- //上传图片
|
|
|
- let dataForms = new FormData();
|
|
|
- dataForms.append('types', "product")
|
|
|
- //将图片的二进制通过表单的形式发送到后台
|
|
|
- fileLists.value.forEach((it, index) => {
|
|
|
- dataForms.append('file', it.file)
|
|
|
- })
|
|
|
- const resourcefiles = await resource.uploadResource(dataForms)
|
|
|
+ }
|
|
|
+ //上传图片
|
|
|
+ let dataForms = new FormData();
|
|
|
+ dataForms.append('types', "product")
|
|
|
+ //将图片的二进制通过表单的形式发送到后台
|
|
|
+ fileLists.value.forEach((it, index) => {
|
|
|
+ dataForms.append('file', it.file)
|
|
|
+ })
|
|
|
+ const resourcefiles = await resource.uploadResource(dataForms)
|
|
|
+ if (resourcefiles.data.Code === 200) {
|
|
|
productDetail.url = resourcefiles.data.Data
|
|
|
- const res = await product.updateProduct({
|
|
|
- id: parseInt(route.query.id),
|
|
|
- title: productDetail.title,
|
|
|
- synopsis: productDetail.synopsis,
|
|
|
- detail: productDetail.detail,
|
|
|
- url: productDetail.url,
|
|
|
- product_introduction: productDetail.product_introduction,
|
|
|
- technical_parameters: productDetail.technical_parameters,
|
|
|
- instructions: productDetail.instructions,
|
|
|
- supporting_software: productDetail.supporting_software,
|
|
|
- optional_accessories: productDetail.optional_accessories,
|
|
|
- });
|
|
|
- if (res.data.Code === 200) {
|
|
|
- ElMessage.success("修改成功")
|
|
|
- } else {
|
|
|
- ElMessage.error(res.data.Msg)
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ const res = await product.updateProduct({
|
|
|
+ id: parseInt(route.query.id),
|
|
|
+ title: productDetail.title,
|
|
|
+ synopsis: productDetail.synopsis,
|
|
|
+ detail: productDetail.detail,
|
|
|
+ url: productDetail.url,
|
|
|
+ type: productDetail.type,
|
|
|
+ ptype: productDetail.ptype,
|
|
|
+ isIndex: productDetail.isIndex,
|
|
|
+ product_introduction: productDetail.product_introduction,
|
|
|
+ technical_parameters: productDetail.technical_parameters,
|
|
|
+ instructions: productDetail.instructions,
|
|
|
+ supporting_software: productDetail.supporting_software,
|
|
|
+ optional_accessories: productDetail.optional_accessories,
|
|
|
+ });
|
|
|
+ if (res.data.Code === 200) {
|
|
|
+ ElMessage.success("修改成功")
|
|
|
+ } else {
|
|
|
+ ElMessage.error(res.data.Msg)
|
|
|
+ }
|
|
|
}
|
|
|
onBeforeMount(async () => {
|
|
|
- if (route.query.id) {
|
|
|
- const res = await product.getProductDetail({ id: route.query.id })
|
|
|
- console.log(res.data)
|
|
|
- Object.assign(productDetail, res.data.Data);
|
|
|
- }
|
|
|
+ if (route.query.id) {
|
|
|
+ const res = await product.getProductDetail({id: route.query.id})
|
|
|
+ getProductType()
|
|
|
+ console.log(res.data)
|
|
|
+ Object.assign(productDetail, res.data.Data);
|
|
|
+ }
|
|
|
})
|
|
|
</script>
|
|
|
|