Browse Source

新增编辑商品

master
tianyi 3 months ago
parent
commit
4bb685b6c7
  1. 41
      src/api/app.js
  2. 89
      src/views/app/shop/addType.vue
  3. 690
      src/views/app/shop/dictManage.vue
  4. 81
      src/views/app/shop/editDictType.vue
  5. 6
      src/views/app/shop/shop.vue
  6. 312
      src/views/sys/oss-manage/ossManage.vue

41
src/api/app.js

@ -46,6 +46,45 @@ export const deleteCompany = (params) => {
return postRequest('/app/company/delByIds', params) return postRequest('/app/company/delByIds', params)
} }
// 新增分类接口
export const addType = (params) => {
return postBodyRequest('/app/productCategory/batchSaveCategoryAndAttribute', params)
}
//编辑分类
export const editType = (params) => {
return postRequest('/app/productCategory/edit', params)
}
//子分类列表
export const categoryList = (params) => {
return postRequest('/app/productAttribute/selectByCategoryId', params)
}
//子分类规格值列表
export const categorySonList = (params) => {
return getRequest('/app/productAttributeValue/selectByAttributeId', params)
}
//新增商品
export const productSave = (params) => {
return postBodyRequest('/app/product/save', params)
}
//编辑商品
export const productEdit = (params) => {
return postBodyRequest('/app/product/edit', params)
}
//商品列表
export const getShareList = (params) => {
return postBodyRequest('/app/product/getShareList', params)
}
//删除分类
export const deleteType = (params) => {
return postRequest('/app/productCategory/delById', params)
}
export const getCompanyData = (params) => { export const getCompanyData = (params) => {
return getRequest('/app/company/getByCondition', params) return getRequest('/app/company/getByCondition', params)
} }
@ -150,7 +189,7 @@ export const addLogisticsRoute = (params) => {
//获取商品分类 //获取商品分类
export const goodsType = (params) => { export const goodsType = (params) => {
return postBodyRequest('/app/productCategory/list', params) return getRequest('/app/productCategory/list', params)
} }
//编辑线路 //编辑线路

89
src/views/app/shop/addType.vue

@ -1,63 +1,29 @@
<template> <template>
<div> <div>
<Modal <Modal title="添加字典" v-model="visible" :mask-closable="false" :width="500">
title="添加字典" <Form ref="form" :model="form" :label-width="85" :rules="formValidate">
v-model="visible" <FormItem label="分类名称" prop="title">
:mask-closable="false" <Input v-model="form.categoryName" />
:width="500"
>
<Form
ref="form"
:model="form"
:label-width="85"
:rules="formValidate"
>
<FormItem label="字典名称" prop="title">
<Input v-model="form.title" />
</FormItem>
<FormItem label="字典类型" prop="type" class="block-tool">
<Tooltip
placement="right"
:max-width="220"
transfer
content="建议设置为英文名且需唯一 非开发人员谨慎修改"
>
<Input v-model="form.type" />
</Tooltip>
</FormItem>
<FormItem label="备注" prop="description">
<Input v-model="form.description" />
</FormItem> </FormItem>
<FormItem label="排序值" prop="sortOrder"> <FormItem label="排序值" prop="sortOrder">
<Tooltip <Tooltip trigger="hover" placement="right" content="值越小越靠前,支持小数">
trigger="hover" <InputNumber :max="1000" :min="0" v-model="form.sort"></InputNumber>
placement="right"
content="值越小越靠前,支持小数"
>
<InputNumber
:max="1000"
:min="0"
v-model="form.sortOrder"
></InputNumber>
</Tooltip> </Tooltip>
</FormItem> </FormItem>
</Form> </Form>
<div slot="footer"> <div slot="footer">
<Button type="text" @click="visible = false">取消</Button> <Button type="text" @click="visible = false">取消</Button>
<Button <Button type="primary" :loading="submitLoading" @click="submit">提交</Button>
type="primary"
:loading="submitLoading"
@click="submit"
>提交</Button
>
</div> </div>
</Modal> </Modal>
</div> </div>
</template> </template>
<script> <script>
import { addDict } from "@/api/index"; import {
export default { addType
} from "@/api/app";
export default {
name: "addDictType", name: "addDictType",
components: {}, components: {},
props: { props: {
@ -74,34 +40,36 @@ export default {
visible: this.value, visible: this.value,
submitLoading: false, submitLoading: false,
form: { form: {
title: "", categoryName: "",
type: "", sort: 0,
description: "", shopId: ''
sortOrder: 0,
}, },
formValidate: { formValidate: {
// //
title: [{ required: true, message: "请输入", trigger: "blur" }], categoryName: [{
type: [{ required: true, message: "请输入", trigger: "blur" }], required: true,
sortOrder: [ message: "请输入",
{ trigger: "blur"
}],
sort: [{
required: true, required: true,
type: "number", type: "number",
message: "请输入排序值", message: "请输入排序值",
trigger: "blur", trigger: "blur",
}, }, ],
],
}, },
}; };
}, },
methods: { methods: {
init() {}, init(v) {
this.form.shopId = v
},
submit() { submit() {
this.$refs.form.validate((valid) => { this.$refs.form.validate((valid) => {
if (valid) { if (valid) {
// //
this.submitLoading = true; this.submitLoading = true;
addDict(this.form).then((res) => { addType(this.form).then((res) => {
this.submitLoading = false; this.submitLoading = false;
if (res.success) { if (res.success) {
this.$Message.success("操作成功"); this.$Message.success("操作成功");
@ -118,7 +86,7 @@ export default {
} }
// //
this.$refs.form.resetFields(); this.$refs.form.resetFields();
this.form.sortOrder = this.dataLength; this.form.sort = this.dataLength;
this.visible = value; this.visible = value;
}, },
}, },
@ -133,10 +101,9 @@ export default {
mounted() { mounted() {
this.init(); this.init();
}, },
}; };
</script> </script>
<style lang="less"> <style lang="less">
@import "@/styles/drawer-common.less"; @import "@/styles/drawer-common.less";
</style> </style>

690
src/views/app/shop/dictManage.vue

@ -1,6 +1,56 @@
<style lang="less"> <style lang="less">
@import "@/styles/tree&table-common.less"; @import "@/styles/tree&table-common.less";
@import "./dictManage.less"; @import "./dictManage.less";
.btn{
width: 80px;
height: 30px;
text-align: center;
line-height: 30px;
background: #008ba0;
color:#fff;
border-right:1px solid #fff;
}
.content-left {
width: 80px;
background: #eee;
height: 475px;
overflow: scroll;
scrollbar-width: none;
}
.left-box {
width: 100%;
height: 50px;
font-size: 14px;
text-align: center;
line-height: 50px;
border-bottom: 1px solid #fff;
}
.left-box-hover {
width: 100%;
height: 50px;
font-size: 14px;
text-align: center;
line-height: 50px;
border-bottom: 1px solid #fff;
background-color: #fff;
}
.red {
border-right: 3px solid red;
}
.content-low{
height: 50px;
padding: 3px 5px;
border:1px solid #eee;
display: inline;
margin-right: 5px;
font-weight: bold;
}
.checked{
background: #60F3FF;
color: #fff !important;
}
</style> </style>
<template> <template>
<div class="search"> <div class="search">
@ -58,7 +108,7 @@
</Row> </Row>
<Row align="middle" justify="space-between" class="operation"> <Row align="middle" justify="space-between" class="operation">
<div> <div>
<Button @click="add" type="primary" icon="md-add">添加数据</Button> <Button @click="add" type="primary" icon="md-add">新增商品</Button>
<Button @click="delAll" icon="md-trash">批量删除</Button> <Button @click="delAll" icon="md-trash">批量删除</Button>
</div> </div>
<div class="icons"> <div class="icons">
@ -94,7 +144,7 @@
<Table :loading="loading" border :columns="columns" :data="data" :size="tableSize" sortable="custom" <Table :loading="loading" border :columns="columns" :data="data" :size="tableSize" sortable="custom"
@on-sort-change="changeSort" @on-selection-change="showSelect" ref="table"></Table> @on-sort-change="changeSort" @on-selection-change="showSelect" ref="table"></Table>
<Row type="flex" justify="end" class="page"> <Row type="flex" justify="end" class="page">
<Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize" <Page :current="searchForm.pageNum" :total="total" :page-size="searchForm.pageSize"
@on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10, 20, 50]" @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10, 20, 50]"
size="small" show-total show-elevator show-sizer></Page> size="small" show-total show-elevator show-sizer></Page>
</Row> </Row>
@ -102,68 +152,175 @@
</Row> </Row>
</Card> </Card>
<addType :dataLength="dataLength" v-model="showAddDict" @on-submit="getAllDict" /> <addType ref="addTypePage" :dataLength="dataLength" v-model="showAddDict" @on-submit="getGoodsType" />
<editDictType :data="dictForm" v-model="showEditDict" @on-submit="editDictSuccess" /> <editDictType ref="editTypePage" :data="dictForm" v-model="showEditDict" @on-submit="editDictSuccess" />
<Modal :title="modalTitle" v-model="modalVisible" :mask-closable="false" :width="500"> <Modal :title="modalTitle" v-model="modalVisible" :mask-closable="false" :width="screenWidth *0.9">
<Form ref="form" :model="form" :label-width="80" :rules="formValidate"> <Form ref="form" :model="form" :label-width="80" :rules="formValidate">
<Col span="6">
<FormItem label="商品图标" class="form-noheight">
<upload-pic-input v-model="addGoodsForm.productPicture"></upload-pic-input>
</FormItem>
</Col>
<Col span="6">
<FormItem label="名称" prop="title"> <FormItem label="名称" prop="title">
<Input v-model="form.title" /> <Input v-model="addGoodsForm.productName" />
</FormItem> </FormItem>
<FormItem label="数据值" prop="value"> </Col>
<Input v-model="form.value" /> <Col span="6">
<FormItem label="店铺分类" class="form-noheight">
<Input v-model="editTitle" disabled />
</FormItem> </FormItem>
<FormItem label="备注" prop="description"> </Col>
<Input v-model="form.description" /> <Col span="6">
<FormItem label="商品规格" class="form-noheight">
<div>
<div v-for="(item,index) in addGoodsForm.attributeListPrice" style="display: flex;margin-top:5px;">
<Input v-model="item.specName" v-if="item.specName != ''&& addGoodsForm.attributeListPrice.length != 1" style="padding-right: 10px;" disabled />
<Input v-model="item.specPrice" style="padding-right: 10px;" placeholder="商品价格" />
<Input v-model="item.specNum" style="padding-right: 10px;" placeholder="商品库存"/>
<button @click="deldantiaoguige(index)" v-if="addGoodsForm.attributeListPrice.length>1" style="width: 120px;height: 30px;line-height: 30px;color: red;border:none;background: #fff;">删除</button>
</div>
<div @click="checkSpec('guige')" style="margin-top:5px;width: 80px;height: 30px;text-align: center;line-height: 30px;background: #008ba0;color:#fff;">
选择规格
</div>
</div>
</FormItem> </FormItem>
<FormItem label="排序值" prop="sortOrder"> </Col>
<Tooltip trigger="hover" placement="right" content="值越小越靠前,支持小数"> <Col span="6">
<InputNumber :max="1000" :min="0" v-model="form.sortOrder"></InputNumber> <FormItem label="拼团信息" class="form-noheight">
</Tooltip> <div>
<div v-for="(item,index) in addGoodsForm.productGroupBuyPrices" style="display: flex;margin-top:5px;">
<Input v-model="item.groupCount" style="padding-right: 10px;" placeholder="成团人数" />
<Input v-model="item.groupPrice" style="padding-right: 10px;" placeholder="成团价格"/>
<button @click="delGroup(index)" v-if="addGoodsForm.productGroupBuyPrices.length>1" style="width: 120px;height: 30px;line-height: 30px;color: red;border:none;background: #fff;">删除</button>
</div>
<div @click="addGroup()" style="margin-top:5px;width: 80px;height: 30px;text-align: center;line-height: 30px;background: #008ba0;color:#fff;">
新增拼团
</div>
</div>
</FormItem> </FormItem>
<FormItem label="是否启用" prop="status"> </Col>
<i-switch size="large" v-model="form.status" :true-value="0" :false-value="-1"> <Col span="6">
<span slot="open">启用</span> <FormItem label="餐盒费" class="form-noheight">
<span slot="close">禁用</span> <Input v-model="addGoodsForm.lunchBox" />
</i-switch> </FormItem>
</Col>
<Col span="6">
<FormItem label="商品属性" class="form-noheight">
<div style="display: flex;flex-direction: column;">
<div v-for="(value,key) in Array.from(addGoodsForm.attributeList1)" style="display: flex;">
{{value[0]}}:
<div v-for="(item,index) in value[1].title">
{{item}}
</div>
</div>
<div @click="checkSpec('shuxing')" style="width: 80px;height: 30px;text-align: center;line-height: 30px;background: #008ba0;color:#fff;">
选择属性
</div>
</div>
</FormItem>
</Col>
<Col span="6">
<FormItem label="起售数量" class="form-noheight">
<Input v-model="addGoodsForm.startPayNum" type="number" placeholder="每笔订单起购数量" />
</FormItem>
</Col>
<Col span="8">
<FormItem label="可售时间" class="form-noheight">
<div>
<div style="line-height: 37px;">
<input type="radio" :checked="addGoodsForm.sellTime==0" name="sellTime" @click="checkSellTime('0')" />全时段售卖
<input type="radio" :checked="addGoodsForm.sellTime==1" name="sellTime" @click="checkSellTime('1')" />自定义时段
</div>
</div>
<div style="display: flex;" v-if="addGoodsForm.sellTime == 1">
<TimePicker format="HH:mm" v-model="addGoodsForm.sellBeginTime" @on-change="selectDateRange" placeholder="选择起始时间"/>
<div style="width: 10px;height: 10px;"></div>
<TimePicker format="HH:mm" v-model="addGoodsForm.sellEndTime" @on-change="selectDateRange" placeholder="选择结束时间"/>
</div>
</FormItem> </FormItem>
</Col>
<Col span="8">
<FormItem label="详细图文" class="form-noheight">
<div style="width:500px;height:400px;">
<editor v-model="addGoodsForm.productIntro" height="250"></editor>
</div>
</FormItem>
</Col>
</Form> </Form>
<div slot="footer"> <div slot="footer">
<Button type="text" @click="modalVisible = false">取消</Button> <Button type="text" @click="modalVisible = false">取消</Button>
<Button type="primary" :loading="submitLoading" @click="handelSubmit">提交</Button> <Button type="primary" :loading="submitLoading" @click="handelSubmit">提交</Button>
</div> </div>
</Modal> </Modal>
<Modal :title="modalTitle" v-model="modalclass" :mask-closable="false" :width="700">
<div style="height:500px;">
<div class="content-left" style="float: left;">
<div class="left-box" v-for="(item,index) in categoryData" :key="index"
:class="item.parentId ? 'left-box-hover':''" @click="clickLeftBtn(index)">
<span style="width: 100%;height: 50px;line-height: 50px;display: inline-block;overflow: hidden;"
:class="item.parentId ? 'red' :''">{{item.title}}</span>
</div>
</div>
<div v-for="(item,index) in categorySonData" :key="index" @click="checkSpecValue(index)" class="content-low" :class="item.checked?'checked':''">
{{item.title}}
</div>
</div>
<div slot="footer">
<Button type="text" @click="modalclass = false">取消</Button>
<Button type="primary" :loading="submitLoading" @click="guigeSubmit">提交</Button>
</div>
</Modal>
</div> </div>
</template> </template>
<script> <script>
import { import {
goodsType,
deleteDict,
searchDict, searchDict,
getAllDictDataList, getAllDictDataList,
addDictData, addDictData,
editDictData, editDictData,
deleteData, deleteData,
} from "@/api/index"; } from "@/api/index";
import {
goodsType,
deleteType,
categoryList,
categorySonList,
productSave,
getShareList,
productEdit
} from "@/api/app";
import addType from "./addType.vue"; import addType from "./addType.vue";
import editDictType from "./editDictType.vue"; import editDictType from "./editDictType.vue";
import uploadPicInput from "@/views/my-components/hiver/upload-pic-input";
import editor from "@/views/my-components/hiver/editor";
import dict from "@/views/my-components/hiver/dict";
export default { export default {
name: "dic-manage", name: "dic-manage",
components: { components: {
addType, addType,
editDictType editDictType,
uploadPicInput,
dict,
editor
}, },
data() { data() {
return { return {
Visiable: false, Visiable: false,
specValueArr:[],
attrValueArr:[],
modalclassType:'',
shopId: '',
tableSize: "default", tableSize: "default",
dataLength: 0, dataLength: 0,
showAddDict: false, showAddDict: false,
dictForm: {}, dictForm: {},
showEditDict: false, showEditDict: false,
openSearch: true, openSearch: true,
categoryIndex: 0,
openTip: true, openTip: true,
treeLoading: false, // treeLoading: false, //
maxHeight: "500px", maxHeight: "500px",
@ -174,19 +331,30 @@
span: 18, span: 18,
expandIcon: "ios-arrow-back", expandIcon: "ios-arrow-back",
selectNode: {}, selectNode: {},
categoryData:[],
categorySonData:[],
treeData: [], // treeData: [], //
selectList: [], // selectList: [], //
searchForm: { searchForm: {
// data // data
name: "", categoryId: "",
status: "", shopId:'',
pageNumber: 1, // order: "",
pageSize: 10, // pageNum: 1,
sort: "sortOrder", // pageSize: "10",
order: "asc", // searchStr: "",
sort: ""
// name: "",
// status: "",
// pageSize: 10, //
// sort: "sort", //
// order: "asc", //
}, },
modalType: 0, // modalType: 0, //
modalVisible: false, // modalVisible: false, //
modalclass:false,
modalTitle: "", // modalTitle: "", //
form: { form: {
// //
@ -194,26 +362,36 @@
value: "", value: "",
status: 0, status: 0,
description: "", description: "",
sortOrder: 0, sort: 0,
},
addGoodsForm:{
id:'',
shopId:'',
categoryId:'', //id
categoryName:'', //
productPicture:'', //
productName:'', //
lunchBox:0, //
startPayNum:'', //
attributeListPrice:[{ //
specPrice:"",
specNum:9999
}],
sellTime:0, //
sellBeginTime:'', //---
sellEndTime:'', //---
attributeList:'',
productGroupBuyPrices:[],
attributeList1:new Map(), //
productIntro:"" //
}, },
formValidate: { formValidate: {
// //
title: [{ productName: [{
required: true,
message: "请输入",
trigger: "blur"
}],
value: [{
required: true, required: true,
message: "请输入", message: "请输入",
trigger: "blur" trigger: "blur"
}], }]
sortOrder: [{
required: true,
type: "number",
message: "请输入排序值",
trigger: "blur",
}, ],
}, },
columns: [ columns: [
// //
@ -228,65 +406,67 @@
align: "center", align: "center",
}, },
{ {
title: "名称", title: "图片",
key: "title", key: "productPicture",
minWidth: 160,
sortable: true,
},
{
title: "数据值",
key: "value",
minWidth: 160, minWidth: 160,
sortable: true, render: (h, params) => {
return h("img", {
attrs: {
src: params.row.productPicture,
}, },
{ style: {
title: "备注", cursor: "zoom-in",
key: "description", width: "80px",
width: 150, height: "60px",
sortable: true, margin: "10px 0",
"object-fit": "contain",
}, },
{ on: {
title: "排序值", click: () => {
key: "sortOrder", this.showPic(params.row);
width: 100,
align: "center",
sortable: true,
sortType: "asc",
}, },
{
title: "状态",
key: "status",
align: "center",
width: 120,
render: (h, params) => {
let re = "";
if (params.row.status == 0) {
return h("div", [
h("Badge", {
props: {
status: "success",
text: "启用",
}, },
}), });
]);
} else if (params.row.status == -1) {
return h("div", [
h("Badge", {
props: {
status: "error",
text: "禁用",
}, },
}),
]);
}
}, },
{
title: "名称",
key: "productName",
minWidth: 160,
}, },
{ {
title: "创建时间", title: "起售数量",
key: "createTime", key: "startPayNum",
width: 200, width: 150,
sortable: true,
}, },
// {
// title: "",
// key: "status",
// align: "center",
// width: 120,
// render: (h, params) => {
// let re = "";
// if (params.row.status == 0) {
// return h("div", [
// h("Badge", {
// props: {
// status: "success",
// text: "",
// },
// }),
// ]);
// } else if (params.row.status == -1) {
// return h("div", [
// h("Badge", {
// props: {
// status: "error",
// text: "",
// },
// }),
// ]);
// }
// },
// },
{ {
title: "操作", title: "操作",
key: "action", key: "action",
@ -327,22 +507,29 @@
submitLoading: false, // submitLoading: false, //
data: [], // data: [], //
total: 0, // total: 0, //
screenWidth: 0,
}; };
}, },
methods: { methods: {
init() { init(v) {
this.shopId = v.id
this.searchForm.shopId = v.id
this.addGoodsForm.shopId = v.id
this.screenWidth = window.screen.width;
// //
this.getGoodsType(); this.getGoodsType();
// //
this.getDataList(); // this.getDataList();
}, },
getGoodsType() { getGoodsType() {
this.treeLoading = true; this.treeLoading = true;
goodsType().then((res) => { goodsType({
shopId: this.shopId
}).then((res) => {
this.treeLoading = false; this.treeLoading = false;
if (res.success) { if (res.success) {
this.treeData = res.result; this.treeData = res.result;
for(let i=0;i<this.treeData.length;i++){ for (let i = 0; i < this.treeData.length; i++) {
this.treeData[i].title = this.treeData[i].categoryName this.treeData[i].title = this.treeData[i].categoryName
} }
} }
@ -362,8 +549,212 @@
}); });
} else { } else {
// //
this.getAllDict(); this.getGoodsType();
}
},
checkSpec(type){
this.modalclass = true;
this.modalclassType = type
if(type == 'shuxing'){
this.modalTitle = "选择属性";
}else{
this.modalTitle = "选择规格";
}
getAllDictDataList({
name: "",
status: "",
pageNumber: 1,
pageSize: 100000,
sort: 'sortOrder',
order: 'asc',
dictId: '2026945661353725952'
}).then((res) => {
if(res.code == 200){
this.categoryData = res.result.content
for (var i = 0; i < this.categoryData.length; i++) {
if (i == this.categoryIndex) {
this.categoryData[i].parentId = true
} else {
this.categoryData[i].parentId = false
}
}
//parent
this.typeToAttrName = res.result.content[this.categoryIndex].title
this.getCateGorySon(res.result.content[this.categoryIndex].id)
}
});
},
deldantiaoguige(index){
for (var m = 0; m < this.specValueArr.length; m++) {
if(this.specValueArr[m].title == this.addGoodsForm.attributeListPrice[index].specName){
this.specValueArr.splice(m,1)
this.addGoodsForm.attributeListPrice.splice(index,1)
if(this.addGoodsForm.attributeListPrice.length == 1){
this.addGoodsForm.attributeListPrice = {
specName:"",
specPrice:'',
specNum:9999
}
this.specValueArr = []
}
this.$forceUpdate()
return
}
}
},
delGroup(index){
this.addGoodsForm.productGroupBuyPrices.splice(index,1)
},
addGroup(){
let data = {
groupCount:'',
groupPrice:0
} }
this.addGoodsForm.productGroupBuyPrices.push(data)
},
showPic(v) {
let image = new Image();
image.src = v.productPicture;
let viewer = new Viewer(image, {
hidden: function() {
viewer.destroy();
},
});
viewer.show();
},
getCateGorySon(id){
getAllDictDataList({
name: "",
status: "",
pageNumber: 1,
pageSize: 100000,
sort: 'sortOrder',
order: 'asc',
dictId: id
}).then((res) => {
if(res.code == 200){
this.categorySonData = res.result.content
if(this.modalclassType == 'shuxing'){
console.log('属性',this.attrValueArr)
if(this.attrValueArr == ""){
this.attrValueArr = this.addGoodsForm.attributeListPrice
}
for (var i = 0; i < this.categorySonData.length; i++) {
if(this.attrValueArr.length>0){
for (var m = 0; m < this.attrValueArr.length; m++) {
if(this.attrValueArr[m].id == this.categorySonData[i].id){
this.categorySonData[i].checked = true
}else{
this.categorySonData[i].checked = false
}
}
}else{
this.categorySonData[i].checked = false
}
}
}else{
//guige
for (var i = 0; i < this.categorySonData.length; i++) {
if(this.specValueArr.length>0){
for (var m = 0; m < this.specValueArr.length; m++) {
if(this.specValueArr[m].id == this.categorySonData[i].id){
this.categorySonData[i].checked = true
}
}
}else{
this.categorySonData[i].checked = false
}
}
}
}
});
},
//
clickLeftBtn(index) {
for (var i = 0; i < this.categoryData.length; i++) {
if (i == index) {
this.categoryData[i].parentId = true
} else {
this.categoryData[i].parentId = false
}
}
this.categoryIndex = index
this.typeToAttrName = this.categoryData[this.categoryIndex].title
this.getCateGorySon(this.categoryData[this.categoryIndex].id)
},
checkSellTime(type){
this.addGoodsForm.sellTime = type;
},
checkSpecValue(index){
//this.typeToAttrName = res.result.content[this.categoryIndex].title
this.categorySonData[index].checked = !this.categorySonData[index].checked
if(this.modalclassType == 'shuxing'){
if(this.categorySonData[index].checked == true){
this.categorySonData[index].parentName = this.typeToAttrName
this.attrValueArr.push(this.categorySonData[index])
}else{
for(let i=0;i<this.attrValueArr.length;i++){
if(this.categorySonData[index].id == this.attrValueArr[i].id){
this.attrValueArr.splice(i,1)
}
}
}
}else{
//guige
if(this.categorySonData[index].checked == true){
this.specValueArr.push(this.categorySonData[index])
}else{
for(let i=0;i<this.specValueArr.length;i++){
if(this.categorySonData[index].id == this.specValueArr[i].id){
this.specValueArr.splice(i,1)
}
}
}
}
this.$forceUpdate()
},
guigeSubmit(){
if(this.modalclassType == 'shuxing'){
for(let i=0;i<this.attrValueArr.length;i++){
if(this.addGoodsForm.attributeList1.size == 0){
//set has get
let data = {
title:[]
}
data.title.push(this.attrValueArr[i].title)
this.addGoodsForm.attributeList1.set(this.attrValueArr[i].parentName,data)
}else{
if(this.addGoodsForm.attributeList1.has(this.attrValueArr[i].parentName)){
this.addGoodsForm.attributeList1.get(this.attrValueArr[i].parentName).title.push(this.attrValueArr[i].title)
}else{
let data = {
title:[]
}
data.title.push(this.attrValueArr[i].title)
this.addGoodsForm.attributeList1.set(this.attrValueArr[i].parentName,data)
}
}
}
}else{
//guige
this.addGoodsForm.attributeListPrice = []
for(let i=0;i<this.specValueArr.length;i++){
this.addGoodsForm.attributeListPrice.push({
specName:this.specValueArr[i].title,
specPrice:'',
specNum:9999
})
}
}
this.modalclass = false;
}, },
selectTree(v) { selectTree(v) {
if (v.length > 0) { if (v.length > 0) {
@ -377,9 +768,9 @@
let data = JSON.parse(str); let data = JSON.parse(str);
this.selectNode = data; this.selectNode = data;
this.dictForm = data; this.dictForm = data;
this.editTitle = data.title + "(" + data.type + ")"; this.editTitle = data.title;
// //
this.searchForm.pageNumber = 1; this.searchForm.pageNum = 1;
this.searchForm.pageSize = 10; this.searchForm.pageSize = 10;
this.getDataList(); this.getDataList();
} else { } else {
@ -394,7 +785,7 @@
// //
this.selectNode = {}; this.selectNode = {};
this.editTitle = ""; this.editTitle = "";
this.getDataList(); // this.getDataList();
}, },
changeTableSize(v) { changeTableSize(v) {
this.tableSize = v; this.tableSize = v;
@ -418,47 +809,47 @@
} }
}, },
changePage(v) { changePage(v) {
this.searchForm.pageNumber = v; this.searchForm.pageNum = v;
this.getDataList(); // this.getDataList();
this.clearSelectAll(); this.clearSelectAll();
}, },
changePageSize(v) { changePageSize(v) {
this.searchForm.pageSize = v; this.searchForm.pageSize = v;
this.getDataList(); // this.getDataList();
}, },
getDataList() { getDataList() {
this.loading = true; this.loading = true;
if (this.selectNode.id) { // if (this.selectNode.id) {
this.searchForm.dictId = this.selectNode.id; this.searchForm.categoryId = this.selectNode.id;
} else { // } else {
delete this.searchForm.dictId; // delete this.searchForm.dictId;
} // }
if (!this.searchForm.status) { if (!this.searchForm.status) {
this.searchForm.status = ""; this.searchForm.status = "";
} }
getAllDictDataList(this.searchForm).then((res) => { getShareList(this.searchForm).then((res) => {
this.loading = false; this.loading = false;
if (res.success) { if (res.success) {
this.data = res.result.content; this.data = res.result.records;
this.total = res.result.totalElements; this.total = res.result.total;
if (this.data.length == 0 && this.searchForm.pageNumber > 1) { if (this.data.length == 0 && this.searchForm.pageNum > 1) {
this.searchForm.pageNumber -= 1; this.searchForm.pageNum -= 1;
this.getDataList(); this.getDataList();
} }
} }
}); });
}, },
handleSearch() { handleSearch() {
this.searchForm.pageNumber = 1; this.searchForm.pageNum = 1;
this.searchForm.pageSize = 10; this.searchForm.pageSize = 10;
this.getDataList(); // this.getDataList();
}, },
handleReset() { handleReset() {
this.$refs.searchForm.resetFields(); this.$refs.searchForm.resetFields();
this.searchForm.pageNumber = 1; this.searchForm.pageNum = 1;
this.searchForm.pageSize = 10; this.searchForm.pageSize = 10;
// //
this.getDataList(); // this.getDataList();
}, },
changeSort(e) { changeSort(e) {
this.searchForm.sort = e.key; this.searchForm.sort = e.key;
@ -466,7 +857,7 @@
if (e.order == "normal") { if (e.order == "normal") {
this.searchForm.order = ""; this.searchForm.order = "";
} }
this.getDataList(); // this.getDataList();
}, },
showSelect(e) { showSelect(e) {
this.selectList = e; this.selectList = e;
@ -475,15 +866,15 @@
this.$refs.table.selectAll(false); this.$refs.table.selectAll(false);
}, },
refreshDict() { refreshDict() {
this.getAllDict(); this.getGoodsType();
this.selectNode = {}; this.selectNode = {};
this.editTitle = ""; this.editTitle = "";
this.getDataList(); // this.getDataList();
}, },
handleDropdown(name) { handleDropdown(name) {
if (name == "editDict") { if (name == "editDict") {
if (!this.selectNode.id) { if (!this.selectNode.id) {
this.$Message.warning("您还未选择要编辑的字典"); this.$Message.warning("您还未选择要编辑的分类");
return; return;
} }
this.handleEditDict(); this.handleEditDict();
@ -496,9 +887,11 @@
handleAddDict() { handleAddDict() {
this.dataLength = this.treeData.length + 1; this.dataLength = this.treeData.length + 1;
this.showAddDict = true; this.showAddDict = true;
this.$refs.addTypePage.init(this.shopId)
}, },
handleEditDict() { handleEditDict() {
this.showEditDict = true; this.showEditDict = true;
this.$refs.editTypePage.init(this.shopId)
}, },
editDictSuccess(v) { editDictSuccess(v) {
for (let attr in v) { for (let attr in v) {
@ -510,21 +903,22 @@
let data = JSON.parse(str); let data = JSON.parse(str);
this.dictForm = data; this.dictForm = data;
this.editTitle = v.title + "(" + v.type + ")"; this.editTitle = v.title + "(" + v.type + ")";
this.getAllDict(); this.getGoodsType();
}, },
delDict() { delDict() {
if (!this.selectNode.id) { if (!this.selectNode.id) {
this.$Message.warning("您还未选择要删除的字典"); this.$Message.warning("您还未选择要删除的分类");
return; return;
} }
this.$Modal.confirm({ this.$Modal.confirm({
title: "确认删除", title: "确认删除",
loading: true, loading: true,
content: "您确认要删除字典 " + this.selectNode.title + " 及其所有数据?", content: "您确认要删除分类 " + this.selectNode.title + " 及其所有数据?",
onOk: () => { onOk: () => {
// //
deleteDict({ deleteType({
ids: this.selectNode.id id: this.selectNode.id,
shopId: this.shopId
}).then((res) => { }).then((res) => {
this.$Modal.remove(); this.$Modal.remove();
if (res.success) { if (res.success) {
@ -535,32 +929,32 @@
}, },
}); });
}, },
getChildren(v){ getChildren(v) {
this.Visiable = true; this.Visiable = true;
console.log(v)
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.dialog.initRecharge(v); this.$refs.dialog.initRecharge(v);
}); });
}, },
add() { add() {
if (!this.selectNode.id) { if (!this.selectNode.id) {
this.$Message.warning("请先选择一个字典类别"); this.$Message.warning("请先选择一个分类");
return; return;
} }
this.modalType = 0; this.modalType = 0;
this.modalTitle = "添加字典 " + this.editTitle + " 的数据"; this.modalTitle = "添加分类 " + this.editTitle + " 的数据";
this.$refs.form.resetFields(); this.$refs.form.resetFields();
this.form.sortOrder = this.data.length + 1; this.form.sort = this.data.length + 1;
this.addGoodsForm.categoryId = this.selectNode.id
this.addGoodsForm.categoryName = this.selectNode.categoryName
this.modalVisible = true; this.modalVisible = true;
}, },
edit(v) { edit(v) {
this.modalType = 1; this.modalType = 1;
if (this.editTitle) { if (this.editTitle) {
this.modalTitle = "编辑字典 " + this.editTitle + " 的数据"; this.modalTitle = "编辑分类 " + this.editTitle + " 的数据";
} else { } else {
this.modalTitle = "编辑字典数据"; this.modalTitle = "编辑分类数据";
} }
this.$refs.form.resetFields();
// null"" // null""
for (let attr in v) { for (let attr in v) {
if (v[attr] == null) { if (v[attr] == null) {
@ -569,32 +963,44 @@
} }
let str = JSON.stringify(v); let str = JSON.stringify(v);
let data = JSON.parse(str); let data = JSON.parse(str);
this.form = data; console.log('111111',data)
this.addGoodsForm = data;
this.addGoodsForm.attributeList1 = JSON.parse(this.addGoodsForm.attributeList)
this.addGoodsForm.attributeList1 = new Map(Object.entries(this.addGoodsForm.attributeList1));
this.addGoodsForm.attributeListPrice = JSON.parse(this.addGoodsForm.attributeListPrice)
this.addGoodsForm.sellTime = this.addGoodsForm.sellBeginTime != '' ? 1 : 0
this.modalVisible = true; this.modalVisible = true;
}, },
handelSubmit() { handelSubmit() {
this.$refs.form.validate((valid) => { this.$refs.form.validate((valid) => {
if (valid) { if (valid) {
this.submitLoading = true; this.submitLoading = true;
if (this.modalType == 0) { if (this.modalType == 0) {
// id // id
delete this.form.id; delete this.addGoodsForm.id;
this.form.dictId = this.selectNode.id; this.addGoodsForm.attributeListPrice = JSON.stringify(this.addGoodsForm.attributeListPrice)
addDictData(this.form).then((res) => { this.addGoodsForm.attributeList = Object.fromEntries(this.addGoodsForm.attributeList1)
this.addGoodsForm.attributeList = JSON.stringify(this.addGoodsForm.attributeList)
productSave(this.addGoodsForm).then((res) => {
this.submitLoading = false; this.submitLoading = false;
if (res.success) { if (res.success) {
this.$Message.success("操作成功"); this.$Message.success("操作成功");
this.getDataList();
this.modalVisible = false; this.modalVisible = false;
} }
}); });
} else if (this.modalType == 1) { } else if (this.modalType == 1) {
// //
editDictData(this.form).then((res) => { this.addGoodsForm.attributeListPrice = JSON.stringify(this.addGoodsForm.attributeListPrice)
this.addGoodsForm.attributeList = Object.fromEntries(this.addGoodsForm.attributeList1)
this.addGoodsForm.attributeList = JSON.stringify(this.addGoodsForm.attributeList)
this.addGoodsForm.productPictures = []
productEdit(this.addGoodsForm).then((res) => {
this.submitLoading = false; this.submitLoading = false;
if (res.success) { if (res.success) {
this.$Message.success("操作成功"); this.$Message.success("操作成功");
this.getDataList(); // this.getDataList();
this.modalVisible = false; this.modalVisible = false;
} }
}); });
@ -616,7 +1022,7 @@
if (res.success) { if (res.success) {
this.clearSelectAll(); this.clearSelectAll();
this.$Message.success("操作成功"); this.$Message.success("操作成功");
this.getDataList(); // this.getDataList();
} }
}); });
}, },
@ -645,7 +1051,7 @@
if (res.success) { if (res.success) {
this.$Message.success("操作成功"); this.$Message.success("操作成功");
this.clearSelectAll(); this.clearSelectAll();
this.getDataList(); // this.getDataList();
} }
}); });
}, },

81
src/views/app/shop/editDictType.vue

@ -1,55 +1,29 @@
<template> <template>
<div> <div>
<Modal <Modal title="编辑分类" v-model="visible" :mask-closable="false" :width="500">
title="编辑字典"
v-model="visible"
:mask-closable="false"
:width="500"
>
<Form ref="form" :model="form" :label-width="85" :rules="formValidate"> <Form ref="form" :model="form" :label-width="85" :rules="formValidate">
<FormItem label="字典名称" prop="title"> <FormItem label="分类名称" prop="title">
<Input v-model="form.title" /> <Input v-model="form.categoryName" />
</FormItem> </FormItem>
<FormItem label="字典类型" prop="type" class="block-tool"> <FormItem label="排序值" prop="sort">
<Tooltip <Tooltip trigger="hover" placement="right" content="值越小越靠前,支持小数">
placement="right" <InputNumber :max="1000" :min="0" v-model="form.sort"></InputNumber>
:max-width="220"
transfer
content="建议设置为英文名且需唯一 非开发人员谨慎修改"
>
<Input v-model="form.type" />
</Tooltip>
</FormItem>
<FormItem label="备注" prop="description">
<Input v-model="form.description" />
</FormItem>
<FormItem label="排序值" prop="sortOrder">
<Tooltip
trigger="hover"
placement="right"
content="值越小越靠前,支持小数"
>
<InputNumber
:max="1000"
:min="0"
v-model="form.sortOrder"
></InputNumber>
</Tooltip> </Tooltip>
</FormItem> </FormItem>
</Form> </Form>
<div slot="footer"> <div slot="footer">
<Button type="text" @click="visible = false">取消</Button> <Button type="text" @click="visible = false">取消</Button>
<Button type="primary" :loading="submitLoading" @click="submit" <Button type="primary" :loading="submitLoading" @click="submit">提交</Button>
>提交</Button
>
</div> </div>
</Modal> </Modal>
</div> </div>
</template> </template>
<script> <script>
import { editDict } from "@/api/index"; import {
export default { editType
} from "@/api/app";
export default {
name: "addDictType", name: "addDictType",
components: {}, components: {},
props: { props: {
@ -63,37 +37,39 @@ export default {
}, },
data() { data() {
return { return {
shopId:'',
visible: this.value, visible: this.value,
submitLoading: false, submitLoading: false,
form: { form: {
title: "", categoryName: "",
type: "", sort: "",
description: "", shopId:''
sortOrder: 0,
}, },
formValidate: { formValidate: {
// //
title: [{ required: true, message: "请输入", trigger: "blur" }], categoryName: [{
type: [{ required: true, message: "请输入", trigger: "blur" }], required: true,
sortOrder: [ message: "请输入",
{ trigger: "blur"
}],
sort: [{
required: true, required: true,
type: "number",
message: "请输入排序值", message: "请输入排序值",
trigger: "blur", trigger: "blur",
}, }, ],
],
}, },
}; };
}, },
methods: { methods: {
init() {}, init(v) {
this.form.shopId = v
},
submit() { submit() {
this.$refs.form.validate((valid) => { this.$refs.form.validate((valid) => {
if (valid) { if (valid) {
// //
this.submitLoading = true; this.submitLoading = true;
editDict(this.form).then((res) => { editType(this.form).then((res) => {
this.submitLoading = false; this.submitLoading = false;
if (res.success) { if (res.success) {
this.$Message.success("操作成功"); this.$Message.success("操作成功");
@ -134,10 +110,9 @@ export default {
mounted() { mounted() {
this.init(); this.init();
}, },
}; };
</script> </script>
<style lang="less"> <style lang="less">
@import "@/styles/drawer-common.less"; @import "@/styles/drawer-common.less";
</style> </style>

6
src/views/app/shop/shop.vue

@ -675,9 +675,9 @@
}, },
goodsList(v){ goodsList(v){
this.Visiable = true; this.Visiable = true;
// this.$nextTick(() => { this.$nextTick(() => {
// this.$refs.dialog.initRecharge(v); this.$refs.goodsPage.init(v);
// }); });
}, },
edit(v) { edit(v) {
// null"" // null""

312
src/views/sys/oss-manage/ossManage.vue

@ -1,7 +1,7 @@
<style lang="less"> <style lang="less">
@import "@/styles/tree&table-common.less"; @import "@/styles/tree&table-common.less";
@import "@/styles/table-common.less"; @import "@/styles/table-common.less";
@import "./ossManage.less"; @import "./ossManage.less";
</style> </style>
<template> <template>
<div class="search"> <div class="search">
@ -9,50 +9,26 @@
<Row v-show="openSearch" @keydown.enter.native="handleSearch"> <Row v-show="openSearch" @keydown.enter.native="handleSearch">
<Form ref="searchForm" :model="searchForm" inline :label-width="85"> <Form ref="searchForm" :model="searchForm" inline :label-width="85">
<FormItem label="原文件名" prop="title"> <FormItem label="原文件名" prop="title">
<Input <Input type="text" v-model="searchForm.title" placeholder="请输入文件名" clearable
type="text" style="width: 200px" />
v-model="searchForm.title"
placeholder="请输入文件名"
clearable
style="width: 200px"
/>
</FormItem> </FormItem>
<FormItem label="上传者账号" prop="createBy"> <FormItem label="上传者账号" prop="createBy">
<Input <Input type="text" v-model="searchForm.createBy" placeholder="请输入上传者登录账号" clearable
type="text" style="width: 200px" />
v-model="searchForm.createBy"
placeholder="请输入上传者登录账号"
clearable
style="width: 200px"
/>
</FormItem> </FormItem>
<span v-if="drop"> <span v-if="drop">
<FormItem label="存储文件名" prop="fKey"> <FormItem label="存储文件名" prop="fKey">
<Input <Input type="text" v-model="searchForm.fkey" placeholder="请输入存储文件名" clearable
type="text" style="width: 200px" />
v-model="searchForm.fkey"
placeholder="请输入存储文件名"
clearable
style="width: 200px"
/>
</FormItem> </FormItem>
<FormItem label="创建时间"> <FormItem label="创建时间">
<DatePicker <DatePicker :options="options" v-model="selectDate" type="daterange" format="yyyy-MM-dd"
:options="options" clearable @on-change="selectDateRange" placeholder="选择起始时间" style="width: 200px">
v-model="selectDate" </DatePicker>
type="daterange"
format="yyyy-MM-dd"
clearable
@on-change="selectDateRange"
placeholder="选择起始时间"
style="width: 200px"
></DatePicker>
</FormItem> </FormItem>
</span> </span>
<FormItem style="margin-left: -35px" class="br"> <FormItem style="margin-left: -35px" class="br">
<Button @click="handleSearch" type="primary" icon="ios-search" <Button @click="handleSearch" type="primary" icon="ios-search">搜索</Button>
>搜索</Button
>
<Button @click="handleReset">重置</Button> <Button @click="handleReset">重置</Button>
<a class="drop-down" @click="dropDown"> <a class="drop-down" @click="dropDown">
{{ dropDownContent }} {{ dropDownContent }}
@ -63,33 +39,18 @@
</Row> </Row>
<Row align="middle" justify="space-between" class="operation"> <Row align="middle" justify="space-between" class="operation">
<div class="br"> <div class="br">
<Button <Button @click="uploadVisible = true" type="primary" icon="md-cloud-upload">上传文件</Button>
@click="uploadVisible = true"
type="primary"
icon="md-cloud-upload"
>上传文件</Button
>
<Dropdown @on-click="handleDropdown"> <Dropdown @on-click="handleDropdown">
<Button> <Button>
更多操作 更多操作
<Icon type="md-arrow-dropdown" /> <Icon type="md-arrow-dropdown" />
</Button> </Button>
<DropdownMenu slot="list"> <DropdownMenu slot="list">
<DropdownItem v-show="showType == 'list'" name="removeAll" <DropdownItem v-show="showType == 'list'" name="removeAll">批量删除</DropdownItem>
>批量删除</DropdownItem <DropdownItem v-show="showType == 'thumb'" name="title">原名称排序</DropdownItem>
> <DropdownItem v-show="showType == 'thumb'" name="size">文件大小排序</DropdownItem>
<DropdownItem v-show="showType == 'thumb'" name="title" <DropdownItem v-show="showType == 'thumb'" name="type">文件类型排序</DropdownItem>
>原名称排序</DropdownItem <DropdownItem v-show="showType == 'thumb'" name="time">创建时间排序</DropdownItem>
>
<DropdownItem v-show="showType == 'thumb'" name="size"
>文件大小排序</DropdownItem
>
<DropdownItem v-show="showType == 'thumb'" name="type"
>文件类型排序</DropdownItem
>
<DropdownItem v-show="showType == 'thumb'" name="time"
>创建时间排序</DropdownItem
>
<DropdownItem name="config">存储配置</DropdownItem> <DropdownItem name="config">存储配置</DropdownItem>
</DropdownMenu> </DropdownMenu>
</Dropdown> </Dropdown>
@ -97,42 +58,15 @@
<div class="icons"> <div class="icons">
<Tooltip content="刷新" placement="top" transfer> <Tooltip content="刷新" placement="top" transfer>
<Icon <Icon type="md-refresh" size="18" class="item" @click="getDataList" />
type="md-refresh"
size="18"
class="item"
@click="getDataList"
/>
</Tooltip> </Tooltip>
<Tooltip <Tooltip :content="openSearch ? '关闭搜索' : '开启搜索'" placement="top" transfer>
:content="openSearch ? '关闭搜索' : '开启搜索'" <Icon type="ios-search" size="18" class="item tip" @click="openSearch = !openSearch" />
placement="top"
transfer
>
<Icon
type="ios-search"
size="18"
class="item tip"
@click="openSearch = !openSearch"
/>
</Tooltip> </Tooltip>
<Tooltip <Tooltip :content="openTip ? '关闭提示' : '开启提示'" placement="top" transfer>
:content="openTip ? '关闭提示' : '开启提示'" <Icon type="md-bulb" size="18" class="item tip" @click="openTip = !openTip" />
placement="top"
transfer
>
<Icon
type="md-bulb"
size="18"
class="item tip"
@click="openTip = !openTip"
/>
</Tooltip> </Tooltip>
<Select <Select v-model="fileType" style="width: 150px; margin: 0 25px 0 15px" @on-change="changeFileType">
v-model="fileType"
style="width: 150px; margin: 0 25px 0 15px"
@on-change="changeFileType"
>
<Option value="all">所有文件</Option> <Option value="all">所有文件</Option>
<Option value="word">Word</Option> <Option value="word">Word</Option>
<Option value="excel">Excel</Option> <Option value="excel">Excel</Option>
@ -145,11 +79,7 @@
<Option value="zip">ZIP</Option> <Option value="zip">ZIP</Option>
<Option value="rar">RAR</Option> <Option value="rar">RAR</Option>
</Select> </Select>
<RadioGroup <RadioGroup v-model="showType" type="button" @on-change="changeShowType">
v-model="showType"
type="button"
@on-change="changeShowType"
>
<Radio title="列表" label="list"> <Radio title="列表" label="list">
<Icon type="md-list"></Icon> <Icon type="md-list"></Icon>
</Radio> </Radio>
@ -165,36 +95,18 @@
已选择 已选择
<span class="select-count">{{ selectList.length }}</span> <span class="select-count">{{ selectList.length }}</span>
<a class="select-clear" @click="clearSelectAll">清空</a> <a class="select-clear" @click="clearSelectAll">清空</a>
<span v-if="selectList.length > 0" style="margin-left: 15px" <span v-if="selectList.length > 0" style="margin-left: 15px">共计 {{ totalSize }} 存储量</span>
>共计 {{ totalSize }} 存储量</span
>
</Alert> </Alert>
<Table <Table :loading="loading" border :columns="columns" :data="data" ref="table" sortable="custom"
:loading="loading" @on-sort-change="changeSort" @on-selection-change="changeSelect"></Table>
border
:columns="columns"
:data="data"
ref="table"
sortable="custom"
@on-sort-change="changeSort"
@on-selection-change="changeSelect"
></Table>
</div> </div>
<Row type="flex" :gutter="30" v-show="showType == 'thumb'"> <Row type="flex" :gutter="30" v-show="showType == 'thumb'">
<Col :lg="6" :md="12" :xs="12" v-for="(item, i) in data" :key="i"> <Col :lg="6" :md="12" :xs="12" v-for="(item, i) in data" :key="i">
<Card class="oss-card"> <Card class="oss-card">
<div class="content"> <div class="content">
<img <img @click="showPic(item)" v-if="item.type.indexOf('image') >= 0" class="img"
@click="showPic(item)" :src="item.url" />
v-if="item.type.indexOf('image') >= 0" <div v-else-if="item.type.indexOf('video') >= 0" class="video" @click="showVideo(item)">
class="img"
:src="item.url"
/>
<div
v-else-if="item.type.indexOf('video') >= 0"
class="video"
@click="showVideo(item)"
>
<video class="cover"> <video class="cover">
<source :src="item.url + '#t=1'" preload="metadata" /> <source :src="item.url + '#t=1'" preload="metadata" />
</video> </video>
@ -213,11 +125,7 @@
<div class="actions"> <div class="actions">
<div class="btn"> <div class="btn">
<Tooltip content="下载" placement="top"> <Tooltip content="下载" placement="top">
<Icon <Icon @click="download(item)" type="md-download" size="16" />
@click="download(item)"
type="md-download"
size="16"
/>
</Tooltip> </Tooltip>
</div> </div>
<div class="btn"> <div class="btn">
@ -241,34 +149,16 @@
</Col> </Col>
</Row> </Row>
<Row type="flex" justify="end" class="page"> <Row type="flex" justify="end" class="page">
<Page <Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize"
:current="searchForm.pageNumber" @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="pageSizeOpts"
:total="total" size="small" show-total show-elevator show-sizer></Page>
:page-size="searchForm.pageSize"
@on-change="changePage"
@on-page-size-change="changePageSize"
:page-size-opts="pageSizeOpts"
size="small"
show-total
show-elevator
show-sizer
></Page>
</Row> </Row>
</Card> </Card>
<Drawer title="文件上传" closable v-model="uploadVisible" width="500"> <Drawer title="文件上传" closable v-model="uploadVisible" width="500">
<Upload <Upload :action="uploadFileUrl" :headers="accessToken" :on-success="handleSuccess" :on-error="handleError"
:action="uploadFileUrl" :max-size="5120" :on-exceeded-size="handleMaxSize" :before-upload="beforeUpload" multiple type="drag"
:headers="accessToken" ref="up">
:on-success="handleSuccess"
:on-error="handleError"
:max-size="5120"
:on-exceeded-size="handleMaxSize"
:before-upload="beforeUpload"
multiple
type="drag"
ref="up"
>
<div style="padding: 20px 0"> <div style="padding: 20px 0">
<Icon type="ios-cloud-upload" size="52" style="color: #3399ff"></Icon> <Icon type="ios-cloud-upload" size="52" style="color: #3399ff"></Icon>
<p>点击这里或将文件拖拽到这里上传</p> <p>点击这里或将文件拖拽到这里上传</p>
@ -279,12 +169,7 @@
</div> </div>
</Drawer> </Drawer>
<Modal <Modal :title="modalTitle" v-model="modalVisible" :mask-closable="false" :width="500">
:title="modalTitle"
v-model="modalVisible"
:mask-closable="false"
:width="500"
>
<Form ref="form" :model="form" :label-width="95" :rules="formValidate"> <Form ref="form" :model="form" :label-width="95" :rules="formValidate">
<FormItem label="原文件名" prop="title"> <FormItem label="原文件名" prop="title">
<Input v-model="form.title" /> <Input v-model="form.title" />
@ -295,46 +180,38 @@
</Form> </Form>
<div slot="footer"> <div slot="footer">
<Button type="text" @click="handleCancel">取消</Button> <Button type="text" @click="handleCancel">取消</Button>
<Button type="primary" :loading="submitLoading" @click="handleSubmit" <Button type="primary" :loading="submitLoading" @click="handleSubmit">提交</Button>
>提交</Button
>
</div> </div>
</Modal> </Modal>
<Modal <Modal v-model="videoVisible" :title="videoTitle" :width="800" @on-cancel="closeVideo" draggable>
v-model="videoVisible"
:title="videoTitle"
:width="800"
@on-cancel="closeVideo"
draggable
>
<div id="dplayer" style="height: 500px"></div> <div id="dplayer" style="height: 500px"></div>
<div slot="footer"> <div slot="footer">
<span <span>文件类型{{ util.ellipsis(file.type, 30) }} 文件大小{{
>文件类型{{ util.ellipsis(file.type, 30) }} 文件大小{{
file.msize file.msize
}} }}
创建时间{{ file.createTime }}</span 创建时间{{ file.createTime }}</span>
>
</div> </div>
</Modal> </Modal>
</div> </div>
</template> </template>
<script> <script>
import { import {
uploadFile, uploadFile,
checkOssSet, checkOssSet,
getFileListData, getFileListData,
copyFile, copyFile,
renameFile, renameFile,
deleteFile, deleteFile,
} from "@/api/index"; } from "@/api/index";
import DPlayer from "dplayer"; import DPlayer from "dplayer";
import "viewerjs/dist/viewer.css"; import "viewerjs/dist/viewer.css";
import Viewer from "viewerjs"; import Viewer from "viewerjs";
import { shortcuts } from "@/libs/shortcuts"; import {
export default { shortcuts
} from "@/libs/shortcuts";
export default {
name: "oss-manage", name: "oss-manage",
components: {}, components: {},
data() { data() {
@ -380,8 +257,16 @@ export default {
file: {}, file: {},
// //
formValidate: { formValidate: {
title: [{ required: true, message: "请输入", trigger: "blur" }], title: [{
fkey: [{ required: true, message: "请输入", trigger: "blur" }], required: true,
message: "请输入",
trigger: "blur"
}],
fkey: [{
required: true,
message: "请输入",
trigger: "blur"
}],
}, },
submitLoading: false, // submitLoading: false, //
selectList: [], // selectList: [], //
@ -436,8 +321,7 @@ export default {
}); });
} else if (params.row.type.includes("video") > 0) { } else if (params.row.type.includes("video") > 0) {
return h( return h(
"video", "video", {
{
style: { style: {
cursor: "pointer", cursor: "pointer",
width: "80px", width: "80px",
@ -664,8 +548,7 @@ export default {
} }
return h("div", [ return h("div", [
h( h(
"Tag", "Tag", {
{
props: { props: {
color: color, color: color,
}, },
@ -691,8 +574,7 @@ export default {
render: (h, params) => { render: (h, params) => {
return h("div", [ return h("div", [
h( h(
"a", "a", {
{
on: { on: {
click: () => { click: () => {
this.download(params.row); this.download(params.row);
@ -707,9 +589,10 @@ export default {
}, },
}), }),
h( h(
"Dropdown", "Dropdown", {
{ props: {
props: { transfer: true }, transfer: true
},
on: { on: {
"on-click": (v) => { "on-click": (v) => {
this.changeDropDown(params.row, v); this.changeDropDown(params.row, v);
@ -725,11 +608,29 @@ export default {
}, },
}), }),
]), ]),
h("DropdownMenu", { slot: "list" }, [ h("DropdownMenu", {
h("DropdownItem", { props: { name: "share" } }, "文件链接"), slot: "list"
h("DropdownItem", { props: { name: "rename" } }, "重命名"), }, [
h("DropdownItem", { props: { name: "copy" } }, "复制"), h("DropdownItem", {
h("DropdownItem", { props: { name: "remove" } }, "删除"), props: {
name: "share"
}
}, "文件链接"),
h("DropdownItem", {
props: {
name: "rename"
}
}, "重命名"),
h("DropdownItem", {
props: {
name: "copy"
}
}, "复制"),
h("DropdownItem", {
props: {
name: "remove"
}
}, "删除"),
]), ]),
] ]
), ),
@ -761,7 +662,9 @@ export default {
} else if (name == "config") { } else if (name == "config") {
this.$router.push({ this.$router.push({
name: "setting", name: "setting",
query: { name: "oss" }, query: {
name: "oss"
},
}); });
} }
}, },
@ -777,7 +680,9 @@ export default {
onOk: () => { onOk: () => {
this.$router.push({ this.$router.push({
name: "setting", name: "setting",
query: { name: "oss" }, query: {
name: "oss"
},
}); });
}, },
}); });
@ -790,7 +695,7 @@ export default {
let image = new Image(); let image = new Image();
image.src = v.url; image.src = v.url;
let viewer = new Viewer(image, { let viewer = new Viewer(image, {
hidden: function () { hidden: function() {
viewer.destroy(); viewer.destroy();
}, },
}); });
@ -1002,7 +907,10 @@ export default {
content: "您确认要复制文件 " + v.title + " ?", content: "您确认要复制文件 " + v.title + " ?",
loading: true, loading: true,
onOk: () => { onOk: () => {
copyFile({ id: v.id, key: v.fkey }).then((res) => { copyFile({
id: v.id,
key: v.fkey
}).then((res) => {
this.$Modal.remove(); this.$Modal.remove();
if (res.success) { if (res.success) {
this.$Message.success("复制文件成功,新文件名为 副本_" + v.title); this.$Message.success("复制文件成功,新文件名为 副本_" + v.title);
@ -1023,11 +931,13 @@ export default {
loading: true, loading: true,
onOk: () => { onOk: () => {
let ids = ""; let ids = "";
this.selectList.forEach(function (e) { this.selectList.forEach(function(e) {
ids += e.id + ","; ids += e.id + ",";
}); });
ids = ids.substring(0, ids.length - 1); ids = ids.substring(0, ids.length - 1);
deleteFile({ ids: ids }).then((res) => { deleteFile({
ids: ids
}).then((res) => {
this.$Modal.remove(); this.$Modal.remove();
if (res.success) { if (res.success) {
this.$Message.success("批量删除文件成功"); this.$Message.success("批量删除文件成功");
@ -1044,7 +954,9 @@ export default {
content: "您确认要删除文件 " + v.title + " ?", content: "您确认要删除文件 " + v.title + " ?",
loading: true, loading: true,
onOk: () => { onOk: () => {
deleteFile({ ids: v.id }).then((res) => { deleteFile({
ids: v.id
}).then((res) => {
this.$Modal.remove(); this.$Modal.remove();
if (res.success) { if (res.success) {
this.clearSelectAll(); this.clearSelectAll();
@ -1104,5 +1016,5 @@ export default {
mounted() { mounted() {
this.init(); this.init();
}, },
}; };
</script> </script>
Loading…
Cancel
Save