Commit ac6219d7 authored by lanbaoming's avatar lanbaoming

2024-06-17提交

parent 6ee2bc1f
<template> <template>
<div class="app-container"> <div class="app-container">
<doc-alert :title="$t('工作流')" url="https://doc.iocoder.cn/bpm" />
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item :label="$t('组名')" prop="name"> <el-form-item :label="$t('组名')" prop="name">
......
<template> <template>
<div class="app-container"> <div class="app-container">
<doc-alert :title="$t('工作流')" url="https://doc.iocoder.cn/bpm" />
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item :label="$t('流程标识')" prop="key"> <el-form-item :label="$t('流程标识')" prop="key">
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -293,6 +293,7 @@ ...@@ -293,6 +293,7 @@
}}</el-button> }}</el-button>
</div> </div>
</el-dialog> </el-dialog>
<!--转异对话框 lanbm 2024-06-19 添加注释-->
<el-dialog <el-dialog
:title="order.orderNo + $t('订单转异')" :title="order.orderNo + $t('订单转异')"
center center
......
<template> <template>
<div class="app-container"> <div class="app-container">
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item :label="$t('商品编码')" prop="productCode"> <el-form-item :label="$t('商品编码')" prop="productCode">
<el-input v-model.trim="queryParams.productCode" :placeholder="$t('请输入商品编码')" clearable @keyup.enter.native="handleQuery" onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')" /> <el-input
v-model.trim="queryParams.productCode"
:placeholder="$t('请输入商品编码')"
clearable
@keyup.enter.native="handleQuery"
onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')"
/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('海关编码')" prop="customsCode"> <el-form-item :label="$t('海关编码')" prop="customsCode">
<el-input v-model.trim="queryParams.customsCode" :placeholder="$t('请输入海关编码')" clearable @keyup.enter.native="handleQuery" onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')"/> <el-input
v-model.trim="queryParams.customsCode"
:placeholder="$t('请输入海关编码')"
clearable
@keyup.enter.native="handleQuery"
onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')"
/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('商品名称')" prop="titleZh"> <el-form-item :label="$t('商品名称')" prop="titleZh">
<el-input v-model="queryParams.titleZh" :placeholder="$t('请输入商品名称')" clearable @keyup.enter.native="handleQuery" /> <el-input
v-model="queryParams.titleZh"
:placeholder="$t('请输入商品名称')"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('商品类型')" prop="attrId"> <el-form-item :label="$t('商品类型')" prop="attrId">
<el-select v-model="queryParams.typeId" multiple :placeholder="$t('选择商品类型')" clearable @change="handleQuery"> <el-select
<el-option v-for="types in typeList" :key="types.id" :label="$l(types, 'title')" :value="types.id" /> v-model="queryParams.typeId"
multiple
:placeholder="$t('选择商品类型')"
clearable
@change="handleQuery"
>
<el-option
v-for="types in typeList"
:key="types.id"
:label="$l(types, 'title')"
:value="types.id"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item :label="$t('商品特性')" prop="attrId"> <el-form-item :label="$t('商品特性')" prop="attrId">
<el-select v-model="queryParams.attrId" multiple :placeholder="$t('选择商品特性')" clearable @change="handleQuery"> <el-select
<el-option v-for="attr in attrList" :key="attr.id" :label="attr.attrName" :value="attr.id" /> v-model="queryParams.attrId"
multiple
:placeholder="$t('选择商品特性')"
clearable
@change="handleQuery"
>
<el-option
v-for="attr in attrList"
:key="attr.id"
:label="attr.attrName"
:value="attr.id"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
...@@ -39,29 +85,65 @@ ...@@ -39,29 +85,65 @@
</el-form-item> --> </el-form-item> -->
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">{{$t('搜索')}}</el-button> <el-button type="primary" icon="el-icon-search" @click="handleQuery">{{
<el-button icon="el-icon-refresh" @click="resetQuery">{{$t('重置')}}</el-button> $t("搜索")
}}</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">{{
$t("重置")
}}</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 操作工具栏 --> <!-- 操作工具栏 -->
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['ecw:product:create']">{{$t('新增')}}</el-button> <el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['ecw:product:create']"
>{{ $t("新增") }}</el-button
>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-setting" size="mini" @click="handleEdit" v-hasPermi="['ecw:product:attr']">{{$t('批量设置商品属性')}}</el-button> <el-button
type="primary"
plain
icon="el-icon-setting"
size="mini"
@click="handleEdit"
v-hasPermi="['ecw:product:attr']"
>{{ $t("批量设置商品属性") }}</el-button
>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['ecw:product-price:export']" :loading="exportLoading" >{{$t('导出')}}</el-button> <el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['ecw:product-price:export']"
:loading="exportLoading"
>{{ $t("导出") }}</el-button
>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row> </el-row>
<!-- 列表 --> <!-- 列表 -->
<el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange"> <el-table
v-loading="loading"
:data="list"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center"> <el-table-column type="selection" width="55" align="center">
</el-table-column> </el-table-column>
<el-table-column :label="$t('商品编号')" align="center" prop="id" /> <el-table-column :label="$t('商品编号')" align="center" prop="id" />
...@@ -70,7 +152,11 @@ ...@@ -70,7 +152,11 @@
<span>{{ getTypeName(scope.row.typeId) }}</span> <span>{{ getTypeName(scope.row.typeId) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('海关编码')" align="center" prop="customsCode" /> <el-table-column
:label="$t('海关编码')"
align="center"
prop="customsCode"
/>
<el-table-column :label="$t('中文标题')" align="center" prop="titleZh" /> <el-table-column :label="$t('中文标题')" align="center" prop="titleZh" />
<el-table-column :label="$t('英文标题')" align="center" prop="titleEn" /> <el-table-column :label="$t('英文标题')" align="center" prop="titleEn" />
<el-table-column :label="$t('商品属性')" align="center" prop="attrId"> <el-table-column :label="$t('商品属性')" align="center" prop="attrId">
...@@ -81,31 +167,56 @@ ...@@ -81,31 +167,56 @@
<!--商品特性--> <!--商品特性-->
<el-table-column :label="$t('商品图片')" align="center" prop="attrId"> <el-table-column :label="$t('商品图片')" align="center" prop="attrId">
<template slot-scope="scope"> <template slot-scope="scope">
<el-image :src="firstImg(scope.row.imgs)" style="width:50px; height:50px">{{ $t('') }}</el-image> <el-image
:src="firstImg(scope.row.imgs)"
style="width: 50px; height: 50px"
>{{ $t("") }}</el-image
>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="auditStatus" align="center" :label="$t('是否审核')" width="120"> <el-table-column
prop="auditStatus"
align="center"
:label="$t('是否审核')"
width="120"
>
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.auditStatus" @change="handleStatusChange(scope.row, 'auditStatus')"> <el-select
<el-option v-for="auditStatusItem in auditStatusDictDatas" :key="auditStatusItem.id" :label="$l(auditStatusItem, 'label')" :value="parseInt(auditStatusItem.value)" /> v-model="scope.row.auditStatus"
@change="handleStatusChange(scope.row, 'auditStatus')"
>
<el-option
v-for="auditStatusItem in auditStatusDictDatas"
:key="auditStatusItem.id"
:label="$l(auditStatusItem, 'label')"
:value="parseInt(auditStatusItem.value)"
/>
</el-select> </el-select>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('添加人')" align="center" prop="creatorName" /> <el-table-column
:label="$t('添加人')"
align="center"
prop="creatorName"
/>
<el-table-column :label="$t('添加时间')" align="center"> <el-table-column :label="$t('添加时间')" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{parseTime(scope.row.createTime)}}</span> <span>{{ parseTime(scope.row.createTime) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('修改人')" align="center" prop="updaterName" /> <el-table-column
:label="$t('修改人')"
align="center"
prop="updaterName"
/>
<el-table-column :label="$t('修改时间')" align="center"> <el-table-column :label="$t('修改时间')" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{parseTime(scope.row.updateTime)}}</span> <span>{{ parseTime(scope.row.updateTime) }}</span>
</template> </template>
</el-table-column> </el-table-column>
...@@ -115,25 +226,54 @@ ...@@ -115,25 +226,54 @@
</template> </template>
</el-table-column> --> </el-table-column> -->
<el-table-column :label="$t('操作')" align="center" class-name="small-padding fixed-width"> <el-table-column
<template slot-scope="scope"> :label="$t('操作')"
align="center"
<el-button size="mini" type="text" @click="toPriceManager(scope.row)" v-hasPermi="['ecw:product-price:query']">{{$t('路线价格')}}</el-button> class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
@click="toPriceManager(scope.row)"
v-hasPermi="['ecw:product-price:query']"
>{{ $t("路线价格") }}</el-button
>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['ecw:product:update']">{{$t('修改')}}</el-button> <el-button
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['ecw:product:delete']">{{$t('删除')}}</el-button> size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['ecw:product:update']"
>{{ $t("修改") }}</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['ecw:product:delete']"
>{{ $t("删除") }}</el-button
>
<!--要有价格复制权限 lanbm 2024-06-19 添加注释-->
<el-button
v-if="scope.row.auditStatus === 2"
size="mini"
type="text"
icon="el-icon-edit"
@click="copyPrice(scope.row)"
v-hasPermi="['ecw:product:copyPrice']"
>{{ $t("复制价格") }}</el-button
>
<el-button v-if="scope.row.auditStatus===2" size="mini" type="text" icon="el-icon-edit" @click="copyPrice(scope.row)" v-hasPermi="['ecw:product:copyPrice']">{{$t('复制价格')}}</el-button> <!-- <div v-else>
<!-- <div v-else>
<el-button size="mini" type="text" @click="toPriceManager(scope.row)" v-hasPermi="['ecw:product-price:query']">{{$t('路线价格')}}</el-button> <el-button size="mini" type="text" @click="toPriceManager(scope.row)" v-hasPermi="['ecw:product-price:query']">{{$t('路线价格')}}</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['ecw:product:update']">{{$t('修改')}}</el-button> <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['ecw:product:update']">{{$t('修改')}}</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['ecw:product:delete']">{{$t('删除')}}</el-button> <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['ecw:product:delete']">{{$t('删除')}}</el-button>
</div> --> </div> -->
<!-- <el-button v-else size="mini" type="text" icon="el-icon-edit" @click="copyPrice(scope.row)" v-hasPermi="['ecw:product:copyPrice']">{{$t('复制价格')}}</el-button> --> <!-- <el-button v-else size="mini" type="text" icon="el-icon-edit" @click="copyPrice(scope.row)" v-hasPermi="['ecw:product:copyPrice']">{{$t('复制价格')}}</el-button> -->
</template> </template>
<!-- <template v-else> <!-- <template v-else>
<el-button size="mini" type="text" @click="toPriceManager(scope.row)" v-hasPermi="['ecw:product-price:query']">{{$t('路线价格')}}</el-button> <el-button size="mini" type="text" @click="toPriceManager(scope.row)" v-hasPermi="['ecw:product-price:query']">{{$t('路线价格')}}</el-button>
...@@ -146,23 +286,56 @@ ...@@ -146,23 +286,56 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 分页组件 --> <!-- 分页组件 -->
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" @pagination="getList" /> <pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 对话框(添加 / 修改) --> <!-- 对话框(添加 / 修改) -->
<el-dialog :modal="false" :modal-append-to-body="true" :title="title" :visible.sync="open" width="850px" > <el-dialog
<el-form v-if="open" ref="form" :model="form" :rules="rules" label-width="110px"> :modal="false"
:modal-append-to-body="true"
:title="title"
:visible.sync="open"
width="850px"
>
<el-form
v-if="open"
ref="form"
:model="form"
:rules="rules"
label-width="110px"
>
<el-form-item :label="$t('商品类型')" prop="typeId"> <el-form-item :label="$t('商品类型')" prop="typeId">
<el-select v-model="form.typeId" :placeholder="$t('选择商品类型')" clearable> <el-select
<el-option v-for="types in typeList" :key="types.id" :label="types.titleZh" :value="types.id" /> v-model="form.typeId"
:placeholder="$t('选择商品类型')"
clearable
>
<el-option
v-for="types in typeList"
:key="types.id"
:label="types.titleZh"
:value="types.id"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item :label="$t('中文标题')" prop="titleZh"> <el-form-item :label="$t('中文标题')" prop="titleZh">
<el-input v-model="form.titleZh" :placeholder="$t('请输入中文标题')" /> <el-input
v-model="form.titleZh"
:placeholder="$t('请输入中文标题')"
/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('英文标题')" prop="titleEn"> <el-form-item :label="$t('英文标题')" prop="titleEn">
<el-input v-model="form.titleEn" :placeholder="$t('请输入英文标题')" /> <el-input
v-model="form.titleEn"
:placeholder="$t('请输入英文标题')"
/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('商品图片')" prop="img"> <el-form-item :label="$t('商品图片')" prop="img">
...@@ -172,43 +345,97 @@ ...@@ -172,43 +345,97 @@
<el-form-item prop="auditStatus" :label="$t('是否审核')"> <el-form-item prop="auditStatus" :label="$t('是否审核')">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="form.auditStatus"> <el-select v-model="form.auditStatus">
<el-option v-for="auditStatusItem in auditStatusDictDatas" :key="auditStatusItem.id" :label="$l(auditStatusItem, 'label')" :value="parseInt(auditStatusItem.value)" /> <el-option
v-for="auditStatusItem in auditStatusDictDatas"
:key="auditStatusItem.id"
:label="$l(auditStatusItem, 'label')"
:value="parseInt(auditStatusItem.value)"
/>
</el-select> </el-select>
</template> </template>
</el-form-item> </el-form-item>
<el-form-item :label="$t('商品编码')" prop="productCode"> <el-form-item :label="$t('商品编码')" prop="productCode">
<el-input v-model="form.productCode" :placeholder="$t('请输入商品编码')" /> <el-input
v-model="form.productCode"
:placeholder="$t('请输入商品编码')"
/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('海关编码')" prop="customsCode"> <el-form-item :label="$t('海关编码')" prop="customsCode">
<el-input v-model="form.customsCode" :placeholder="$t('请输入海关编码')" /> <el-input
v-model="form.customsCode"
:placeholder="$t('请输入海关编码')"
/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('商品特性')" prop="attrArray"> <el-form-item :label="$t('商品特性')" prop="attrArray">
<el-select v-model="form.attrArray" :placeholder="$t('选择商品特性')" clearable multiple> <el-select
<el-option v-for="attr in attrList" :key="attr.id" :label="attr.attrName" :value="attr.id" /> v-model="form.attrArray"
:placeholder="$t('选择商品特性')"
clearable
multiple
>
<el-option
v-for="attr in attrList"
:key="attr.id"
:label="attr.attrName"
:value="attr.id"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item :label="$t('商品材质')" prop="materialType"> <el-form-item :label="$t('商品材质')" prop="materialType">
<el-select v-model="form.materialType" :placeholder="$t('选择商品材质')" clearable> <el-select
<el-option v-for="materialItem in materialList" :key="materialItem.value" :label="materialItem.label" :value="materialItem.value" /> v-model="form.materialType"
:placeholder="$t('选择商品材质')"
clearable
>
<el-option
v-for="materialItem in materialList"
:key="materialItem.value"
:label="materialItem.label"
:value="materialItem.value"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item :label="$t('出运要求')" prop="requirements"> <el-form-item :label="$t('出运要求')" prop="requirements">
<el-checkbox v-model="form.requirements" :checked="form.requirements===1? true:false" :true-label="1" :false-label="0">{{$t('证书要求')}}({{$t('支持多证书')}})</el-checkbox> <el-checkbox
v-model="form.requirements"
:checked="form.requirements === 1 ? true : false"
:true-label="1"
:false-label="0"
>{{ $t("证书要求") }}({{ $t("支持多证书") }})</el-checkbox
>
</el-form-item> </el-form-item>
<el-form-item :label="$t('包装要求')" prop="packaging"> <el-form-item :label="$t('包装要求')" prop="packaging">
<el-select v-model="form.packaging" :placeholder="$t('选择包装要求')" clearable> <el-select
<el-option v-for="packageItem in packagingList" :key="packageItem.value" :label="packageItem.label" :value="packageItem.value" /> v-model="form.packaging"
:placeholder="$t('选择包装要求')"
clearable
>
<el-option
v-for="packageItem in packagingList"
:key="packageItem.value"
:label="packageItem.label"
:value="packageItem.value"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item :label="$t('默认货柜位置')" prop="containerLocation"> <el-form-item :label="$t('默认货柜位置')" prop="containerLocation">
<el-select v-model="form.containerLocation" :placeholder="$t('选择货柜位置')" clearable> <el-select
<el-option v-for="locationItem in locationList" :key="locationItem.value" :label="locationItem.label" :value="locationItem.value" /> v-model="form.containerLocation"
:placeholder="$t('选择货柜位置')"
clearable
>
<el-option
v-for="locationItem in locationList"
:key="locationItem.value"
:label="locationItem.label"
:value="locationItem.value"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
...@@ -218,54 +445,92 @@ ...@@ -218,54 +445,92 @@
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item :label="$t('是否预约入仓')" prop="needBook"> <el-form-item :label="$t('是否预约入仓')" prop="needBook">
<el-radio v-model.number="form.needBook" :label="1">{{$t('是')}}</el-radio> <el-radio v-model.number="form.needBook" :label="1">{{
<el-radio v-model.number="form.needBook" :label="0">{{$t('否')}}</el-radio> $t("是")
}}</el-radio>
<el-radio v-model.number="form.needBook" :label="0">{{
$t("否")
}}</el-radio>
</el-form-item> </el-form-item>
<!-- <el-form-item :label="$t('可参与优惠活动')" prop="you"> <!-- <el-form-item :label="$t('可参与优惠活动')" prop="you">
<el-select v-model="form.you" :placeholder="$t('可参与优惠活动')" clearable> <el-select v-model="form.you" :placeholder="$t('可参与优惠活动')" clearable>
<el-option v-for="packageItem in packagingList" :key="packageItem.value" :label="packageItem.label" :value="packageItem.value" /> <el-option v-for="packageItem in packagingList" :key="packageItem.value" :label="packageItem.label" :value="packageItem.value" />
</el-select> </el-select>
</el-form-item> --> </el-form-item> -->
<el-form-item :label="$t('每日入仓上限')" prop="dayLimit" v-if="form.needBook==1"> <el-form-item
:label="$t('每日入仓上限')"
prop="dayLimit"
v-if="form.needBook == 1"
>
<el-input v-model.number="form.dayLimit" type="number"> <el-input v-model.number="form.dayLimit" type="number">
<template slot="append">{{$t('立方米')}}</template> <template slot="append">{{ $t("立方米") }}</template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item :label="$t('可参与优惠')"> <el-form-item :label="$t('可参与优惠')">
<div style="width: 300px;height: 400px;border: 1px solid;overflow-y: auto"> <div
<div @click="selectMoveAbout(item)" style="display: flex;justify-content: space-between; align-items: center;" :style="{'cursor':item.mandatory ? 'no-drop' : 'pointer' }" v-for="item in preferentialList" :key="item.couponId" > style="
width: 300px;
height: 400px;
border: 1px solid;
overflow-y: auto;
"
>
<div
@click="selectMoveAbout(item)"
style="
display: flex;
justify-content: space-between;
align-items: center;
"
:style="{ cursor: item.mandatory ? 'no-drop' : 'pointer' }"
v-for="item in preferentialList"
:key="item.couponId"
>
<div> <div>
{{$l(item, 'title')}} {{ $l(item, "title") }}
</div> </div>
<i v-if="form.couponIds.includes(item.couponId)" style="margin-right: 20px;" class="el-icon-check"></i> <i
v-if="form.couponIds.includes(item.couponId)"
style="margin-right: 20px"
class="el-icon-check"
></i>
</div> </div>
</div> </div>
</el-form-item> </el-form-item>
<!-- <el-form-item label-width="150px" label="空运订单重量上限kg">--> <!-- <el-form-item label-width="150px" label="空运订单重量上限kg">-->
<!-- <el-input-number v-model="form.airWeightLimit" controls-position="right" ></el-input-number>--> <!-- <el-input-number v-model="form.airWeightLimit" controls-position="right" ></el-input-number>-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
<!-- <packaging-type key-arr="priceStepClearanceList" v-model="form">--> <!-- <packaging-type key-arr="priceStepClearanceList" v-model="form">-->
<!-- <el-button @click="visible = true; open = false;" type="text">选择空运模板</el-button>--> <!-- <el-button @click="visible = true; open = false;" type="text">选择空运模板</el-button>-->
<!-- </packaging-type>--> <!-- </packaging-type>-->
<!-- <p v-if="lineNum">--> <!-- <p v-if="lineNum">-->
<!-- <span>--> <!-- <span>-->
<!-- 复制模板线路价格:{{lineNum}}个--> <!-- 复制模板线路价格:{{lineNum}}个-->
<!-- </span>--> <!-- </span>-->
<!-- <span @click="toPriceManager(formCopy, true)" style="color: #0a84ff;cursor: pointer;">--> <!-- <span @click="toPriceManager(formCopy, true)" style="color: #0a84ff;cursor: pointer;">-->
<!-- 查看《#{{$l(formCopy,'title')}}#》路线价格--> <!-- 查看《#{{$l(formCopy,'title')}}#》路线价格-->
<!-- </span>--> <!-- </span>-->
<!-- <el-button style="font-size: 12px;margin-left: 15px;color: red;" type="text" @click="form.priceStepClearanceList = [];lineNum = 0" >清除路线</el-button>--> <!-- <el-button style="font-size: 12px;margin-left: 15px;color: red;" type="text" @click="form.priceStepClearanceList = [];lineNum = 0" >清除路线</el-button>-->
<!-- </p>--> <!-- </p>-->
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">{{$t('确定')}}</el-button> <el-button type="primary" @click="submitForm">{{
<el-button @click="cancel">{{$t('取消')}}</el-button> $t("确定")
}}</el-button>
<el-button @click="cancel">{{ $t("取消") }}</el-button>
</div> </div>
</el-dialog> </el-dialog>
<el-dialog width="60%" :visible.sync="visible" @close="()=>{open = true}" > <el-dialog
width="60%"
:visible.sync="visible"
@close="
() => {
open = true;
}
"
>
<product-dialog @copyLine="copyLine"></product-dialog> <product-dialog @copyLine="copyLine"></product-dialog>
</el-dialog> </el-dialog>
</div> </div>
...@@ -279,14 +544,14 @@ import { ...@@ -279,14 +544,14 @@ import {
getProduct, getProduct,
getProductPage, getProductPage,
product_coupon_newProd, product_coupon_newProd,
updateProduct updateProduct,
} from "@/api/ecw/product"; } from "@/api/ecw/product";
import {getProductAttrList} from "@/api/ecw/productAttr"; import { getProductAttrList } from "@/api/ecw/productAttr";
import {getProductTypeList} from "@/api/ecw/productType"; import { getProductTypeList } from "@/api/ecw/productType";
import {DICT_TYPE, getDictDatas} from '@/utils/dict'; import { DICT_TYPE, getDictDatas } from "@/utils/dict";
import {AuditStatusEnum, CommonStatusEnum} from '@/utils/constants'; import { AuditStatusEnum, CommonStatusEnum } from "@/utils/constants";
import {uploadFile} from "@/api/infra/file"; import { uploadFile } from "@/api/infra/file";
import ImageUpload from '@/components/ImageUpload' import ImageUpload from "@/components/ImageUpload";
import PackagingType from "@/views/ecw/channel/componrnts/packaging-type.vue"; import PackagingType from "@/views/ecw/channel/componrnts/packaging-type.vue";
import ProductDialog from "@/views/ecw/product/product-dialog.vue"; import ProductDialog from "@/views/ecw/product/product-dialog.vue";
...@@ -295,11 +560,11 @@ export default { ...@@ -295,11 +560,11 @@ export default {
components: { components: {
ProductDialog, ProductDialog,
PackagingType, PackagingType,
ImageUpload ImageUpload,
}, },
data() { data() {
return { return {
visible:false, visible: false,
// 选中数组 // 选中数组
ids: [], ids: [],
// 非单个禁用 // 非单个禁用
...@@ -344,16 +609,38 @@ export default { ...@@ -344,16 +609,38 @@ export default {
status: null, status: null,
}, },
// 表单参数 // 表单参数
form: { form: {},
formCopy: {},
},
formCopy:{},
// 表单校验 // 表单校验
rules: { rules: {
typeId: [{ required: true, message: this.$t("商品类型不能为空"), trigger: "change" }], typeId: [
attrArray: [{ required: true, message: this.$t("商品特性不能为空"), trigger: "change" }], {
titleZh: [{ required: true, message: this.$t("中文标题不能为空"), trigger: "blur" }], required: true,
titleEn: [{ required: true, message: this.$t("英文标题不能为空"), trigger: "blur" }], message: this.$t("商品类型不能为空"),
trigger: "change",
},
],
attrArray: [
{
required: true,
message: this.$t("商品特性不能为空"),
trigger: "change",
},
],
titleZh: [
{
required: true,
message: this.$t("中文标题不能为空"),
trigger: "blur",
},
],
titleEn: [
{
required: true,
message: this.$t("英文标题不能为空"),
trigger: "blur",
},
],
// materialType: [{ required: true, message: this.$t("商品材质不能为空"), trigger: "blur" }], // materialType: [{ required: true, message: this.$t("商品材质不能为空"), trigger: "blur" }],
// packaging: [{ required: true, message: this.$t("包装要求不能为空"), trigger: "blur" }], // packaging: [{ required: true, message: this.$t("包装要求不能为空"), trigger: "blur" }],
// containerLocation: [{ required: true, message: this.$t("默认货柜位置不能为空"), trigger: "blur" }], // containerLocation: [{ required: true, message: this.$t("默认货柜位置不能为空"), trigger: "blur" }],
...@@ -368,65 +655,65 @@ export default { ...@@ -368,65 +655,65 @@ export default {
materialList: getDictDatas(DICT_TYPE.ECW_PRODUCT_MATERIAL), materialList: getDictDatas(DICT_TYPE.ECW_PRODUCT_MATERIAL),
packagingList: getDictDatas(DICT_TYPE.ECW_PACKAGING_TYPE), packagingList: getDictDatas(DICT_TYPE.ECW_PACKAGING_TYPE),
locationList: getDictDatas(DICT_TYPE.ECW_CONTAINER_LOCATION), locationList: getDictDatas(DICT_TYPE.ECW_CONTAINER_LOCATION),
preferentialList:[], preferentialList: [],
exceptionProductId:0,//新增商品异常传的id exceptionProductId: 0, //新增商品异常传的id
lineNum:0 lineNum: 0,
}; };
}, },
computed: { computed: {
getTypeName() { getTypeName() {
return typeId => { return (typeId) => {
for (let index in this.typeList) { for (let index in this.typeList) {
let typeItem = this.typeList[index]; let typeItem = this.typeList[index];
if (typeItem.id == typeId) { if (typeItem.id == typeId) {
return this.$l(typeItem, 'title'); return this.$l(typeItem, "title");
} }
} }
} };
}, },
getAttrName() { getAttrName() {
return attrIds => { return (attrIds) => {
let productAttrArray = []; let productAttrArray = [];
let attrArray = attrIds.split(','); let attrArray = attrIds.split(",");
for (let attrIndex in attrArray) { for (let attrIndex in attrArray) {
let attrId = attrArray[attrIndex]; let attrId = attrArray[attrIndex];
for (let index in this.attrList) { for (let index in this.attrList) {
let attrItem = this.attrList[index]; let attrItem = this.attrList[index];
if (attrItem.id == attrId) { if (attrItem.id == attrId) {
productAttrArray.push(this.$l(attrItem, 'attrName')); productAttrArray.push(this.$l(attrItem, "attrName"));
} }
} }
} }
return productAttrArray.join(','); return productAttrArray.join(",");
} };
},
firstImg() {
return (imgString) => {
if (!imgString || imgString == "") return imgString;
let imgs = imgString.split(",");
return imgs.length ? imgs[0] : null;
};
}, },
firstImg(){
return imgString => {
if(!imgString || imgString == '') return imgString
let imgs = imgString.split(',')
return imgs.length ? imgs[0] : null
}
}
}, },
activated(){ activated() {
if(this.$route.query.typeId != this.queryParams.typeId){ if (this.$route.query.typeId != this.queryParams.typeId) {
this.queryParams.typeId = +this.$route.query.typeId || null this.queryParams.typeId = +this.$route.query.typeId || null;
} }
//新增商品异常跳转商品修改 //新增商品异常跳转商品修改
if(this.$route.query.prodId){ if (this.$route.query.prodId) {
this.exceptionProductId = this.$route.query.prodId this.exceptionProductId = this.$route.query.prodId;
this.handleUpdate({id:this.$route.query.prodId}) this.handleUpdate({ id: this.$route.query.prodId });
} }
this.getList() this.getList();
}, },
created() { created() {
//新增商品异常跳转商品修改 //新增商品异常跳转商品修改
if(this.$route.query.prodId){ if (this.$route.query.prodId) {
this.exceptionProductId = this.$route.query.prodId this.exceptionProductId = this.$route.query.prodId;
this.handleUpdate({id:this.$route.query.prodId}) this.handleUpdate({ id: this.$route.query.prodId });
} }
let typeId = this.$route.query.typeId; let typeId = this.$route.query.typeId;
if (typeId) { if (typeId) {
...@@ -435,7 +722,6 @@ export default { ...@@ -435,7 +722,6 @@ export default {
this.getAttrList(); this.getAttrList();
this.getTypeList(); this.getTypeList();
this.getList(); this.getList();
}, },
methods: { methods: {
// copyLine(val , bol){ // copyLine(val , bol){
...@@ -493,56 +779,66 @@ export default { ...@@ -493,56 +779,66 @@ export default {
// }, // },
/** 获取产品属性列表 */ /** 获取产品属性列表 */
getAttrList() { getAttrList() {
getProductAttrList().then(response => { getProductAttrList().then((response) => {
this.attrList = response.data; this.attrList = response.data;
}) });
}, },
/** 获取产品类型列表 */ /** 获取产品类型列表 */
getTypeList() { getTypeList() {
getProductTypeList().then(response => { getProductTypeList().then((response) => {
this.typeList = response.data; this.typeList = response.data;
}) });
}, },
/**跳转价格管理 */ /**跳转价格管理 */
toPriceManager(row, flag = false) { toPriceManager(row, flag = false) {
/* localStorage.setItem('product', JSON.stringify(row)); /* localStorage.setItem('product', JSON.stringify(row));
localStorage.setItem('typeList', JSON.stringify(this.typeList)); */ localStorage.setItem('typeList', JSON.stringify(this.typeList)); */
let p let p;
if (flag){ if (flag) {
p = { p = {
product_id: row.id, product_id: row.id,
product_type: row.typeId, product_type: row.typeId,
transportType:3, transportType: 3,
} };
}else { } else {
p = { p = {
product_id: row.id, product_id: row.id,
product_type: row.typeId, product_type: row.typeId,
} };
} }
this.$router.push({ this.$router.push({
name: 'ProductPrice', name: "ProductPrice",
query: p query: p,
}) });
}, },
handleStatusChange(row, statusType) { handleStatusChange(row, statusType) {
updateProduct(row).then(() => { updateProduct(row)
this.$modal.msgSuccess(this.$t("修改成功")); .then(() => {
}).catch(function () { this.$modal.msgSuccess(this.$t("修改成功"));
if (statusType == 'status') { })
row.status = row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE : CommonStatusEnum.ENABLE; .catch(function () {
} else { if (statusType == "status") {
row.auditStatus = row.auditStatus === AuditStatusEnum.PASS ? AuditStatusEnum.NOT_PASS : AuditStatusEnum.PASS; row.status =
} row.status === CommonStatusEnum.ENABLE
? CommonStatusEnum.DISABLE
}); : CommonStatusEnum.ENABLE;
} else {
row.auditStatus =
row.auditStatus === AuditStatusEnum.PASS
? AuditStatusEnum.NOT_PASS
: AuditStatusEnum.PASS;
}
});
}, },
//复制价格 //复制价格
copyPrice(row){ copyPrice(row) {
this.$router.push({path:'/product/copyPrice',query:{titleZh:row.titleZh,id:row.id}}) this.$router.push({
path: "/product/copyPrice",
query: { titleZh: row.titleZh, id: row.id },
});
}, },
/** 查询列表 */ /** 查询列表 */
...@@ -550,11 +846,11 @@ export default { ...@@ -550,11 +846,11 @@ export default {
this.loading = true; this.loading = true;
// 处理查询参数 // 处理查询参数
let params = { ...this.queryParams }; let params = { ...this.queryParams };
params.filter=false; params.filter = false;
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime'); this.addBeginAndEndTime(params, this.dateRangeCreateTime, "createTime");
// 执行查询 // 执行查询
params.status = 0; params.status = 0;
getProductPage(params).then(response => { getProductPage(params).then((response) => {
this.list = response.data.list; this.list = response.data.list;
this.total = response.data.total; this.total = response.data.total;
this.loading = false; this.loading = false;
...@@ -578,14 +874,13 @@ export default { ...@@ -578,14 +874,13 @@ export default {
status: undefined, status: undefined,
requirements: 0, requirements: 0,
needBook: 0, needBook: 0,
couponIds:[], couponIds: [],
airWeightLimit:undefined, airWeightLimit: undefined,
priceStepClearanceList:[], priceStepClearanceList: [],
isCopyProductPriceTemplate:false, isCopyProductPriceTemplate: false,
productTemplateId:undefined, productTemplateId: undefined,
}; };
this.lineNum = 0 this.lineNum = 0;
this.resetForm("form"); this.resetForm("form");
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
...@@ -604,10 +899,12 @@ export default { ...@@ -604,10 +899,12 @@ export default {
this.reset(); this.reset();
this.open = true; this.open = true;
this.title = this.$t("添加商品"); this.title = this.$t("添加商品");
product_coupon_newProd().then(r => { product_coupon_newProd().then((r) => {
this.preferentialList = r.data this.preferentialList = r.data;
this.form.couponIds = this.preferentialList.filter(i => i.isDefault).map(i => i.couponId) this.form.couponIds = this.preferentialList
}) .filter((i) => i.isDefault)
.map((i) => i.couponId);
});
if (this.queryParams.typeId) { if (this.queryParams.typeId) {
this.form.typeId = this.queryParams.typeId; this.form.typeId = this.queryParams.typeId;
} }
...@@ -617,33 +914,41 @@ export default { ...@@ -617,33 +914,41 @@ export default {
// this.reset(); // this.reset();
console.log(row); console.log(row);
const id = row.id; const id = row.id;
getProduct(id).then(response => { getProduct(id).then((response) => {
this.form = {...response.data,couponIds:[]}; this.form = { ...response.data, couponIds: [] };
this.form.channelPriceStepClearanceList = this.form.priceStepClearanceList; this.form.channelPriceStepClearanceList =
let attrArray = this.form.attrId?this.form.attrId.split(','):[]; this.form.priceStepClearanceList;
let attrArray = this.form.attrId ? this.form.attrId.split(",") : [];
for (let index in attrArray) { for (let index in attrArray) {
let value = attrArray[index]; let value = attrArray[index];
attrArray[index] = parseInt(value); attrArray[index] = parseInt(value);
} }
this.$nextTick(() =>{ this.$nextTick(() => {
this.$set(this.form, 'attrArray', attrArray) this.$set(this.form, "attrArray", attrArray);
}) });
this.open = true; this.open = true;
this.title = this.$t("修改商品"); this.title = this.$t("修改商品");
product_coupon_newProd({prodId:id}).then(r => { product_coupon_newProd({ prodId: id }).then((r) => {
this.preferentialList = r.data this.preferentialList = r.data;
this.form.couponIds = this.preferentialList.filter(i => i.isDefault).map(i => i.couponId) this.form.couponIds = this.preferentialList
.filter((i) => i.isDefault)
.map((i) => i.couponId);
// this.reset() // this.reset()
}) });
}); });
}, },
verify(row){ verify(row) {
return (row.startNum !== '' && row.endNum !== '' && row.clearancePrice !== '' && row.clearancePriceUnit !== '' && row.clearanceVolumeUnit !== '') return (
}, row.startNum !== "" &&
row.endNum !== "" &&
row.clearancePrice !== "" &&
row.clearancePriceUnit !== "" &&
row.clearanceVolumeUnit !== ""
);
},
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate((valid) => {
if (!valid) { if (!valid) {
return; return;
} }
...@@ -660,48 +965,52 @@ export default { ...@@ -660,48 +965,52 @@ export default {
// //
// } // }
//商品特性转字符串 //商品特性转字符串
this.form.attrId = this.form.attrArray.join(','); this.form.attrId = this.form.attrArray.join(",");
// 修改的提交 // 修改的提交
if (this.form.id != null) { if (this.form.id != null) {
this.form.priceStepClearanceList.forEach(i =>{ this.form.priceStepClearanceList.forEach((i) => {
i.productId = this.form.id i.productId = this.form.id;
}) });
if(this.exceptionProductId){ if (this.exceptionProductId) {
this.form.productId = this.exceptionProductId this.form.productId = this.exceptionProductId;
this.form.status = 0 this.form.status = 0;
}else { } else {
this.form.productId = this.form.id this.form.productId = this.form.id;
} }
updateProduct(this.form).then(response => { updateProduct(this.form).then((response) => {
this.$modal.msgSuccess(this.$t("修改成功")); this.$modal.msgSuccess(this.$t("修改成功"));
this.open = false; this.open = false;
if(this.exceptionProductId){ if (this.exceptionProductId) {
this.exceptionProductId = null this.exceptionProductId = null;
this.$router.replace({ path: '/product/product-list'}) this.$router.replace({ path: "/product/product-list" });
} }
this.getList(); this.getList();
this.lineNum = 0 this.lineNum = 0;
}); });
return; return;
} }
// 添加的提交 // 添加的提交
createProduct(this.form).then(response => { createProduct(this.form).then((response) => {
this.$modal.msgSuccess(this.$t("新增成功")); this.$modal.msgSuccess(this.$t("新增成功"));
this.open = false; this.open = false;
this.getList(); this.getList();
this.lineNum = 0 this.lineNum = 0;
}); });
}); });
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const id = row.id; const id = row.id;
this.$modal.confirm(this.$t('是否确认删除商品编号为{id}的数据项?', {id})).then(function () { this.$modal
return deleteProduct(id); .confirm(this.$t("是否确认删除商品编号为{id}的数据项?", { id }))
}).then(() => { .then(function () {
this.getList(); return deleteProduct(id);
this.$modal.msgSuccess(this.$t("删除成功")); })
}).catch(() => { }); .then(() => {
this.getList();
this.$modal.msgSuccess(this.$t("删除成功"));
})
.catch(() => {});
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
...@@ -709,30 +1018,38 @@ export default { ...@@ -709,30 +1018,38 @@ export default {
let params = { ...this.queryParams }; let params = { ...this.queryParams };
params.pageNo = undefined; params.pageNo = undefined;
params.pageSize = undefined; params.pageSize = undefined;
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime'); this.addBeginAndEndTime(params, this.dateRangeCreateTime, "createTime");
// 执行导出 // 执行导出
this.$modal.confirm(this.$t('是否确认导出所有商品数据项?')).then(() => { this.$modal
this.exportLoading = true; .confirm(this.$t("是否确认导出所有商品数据项?"))
return exportProductExcel(params); .then(() => {
}).then(response => { this.exportLoading = true;
// this.$download.excel(response, '商品.xlsx'); return exportProductExcel(params);
this.$message.success(this.$t('已加入导出队列,请稍后在下载日志中下载')) })
this.exportLoading = false; .then((response) => {
}).catch(() => { }); // this.$download.excel(response, '商品.xlsx');
this.$message.success(
this.$t("已加入导出队列,请稍后在下载日志中下载")
);
this.exportLoading = false;
})
.catch(() => {});
}, },
// 上传预处理 // 上传预处理
beforeUpload(file) { beforeUpload(file) {
if (file.type.indexOf("image/") == -1) { if (file.type.indexOf("image/") == -1) {
this.$modal.msgError(this.$t("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。")); this.$modal.msgError(
this.$t("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。")
);
} else { } else {
//上传 //上传
let formData = new FormData(); let formData = new FormData();
formData.append("file", file); formData.append("file", file);
// formData.append("path", this.uuid()); // formData.append("path", this.uuid());
uploadFile(formData).then(response => { uploadFile(formData).then((response) => {
this.$set(this.form, 'imgs', response.data); this.$set(this.form, "imgs", response.data);
// this.form.img = response.data; // this.form.img = response.data;
}) });
} }
}, },
...@@ -751,51 +1068,62 @@ export default { ...@@ -751,51 +1068,62 @@ export default {
}, },
// 表格多选 // 表格多选
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.id) this.ids = selection.map((item) => item.id);
this.single = selection.length !== 1 this.single = selection.length !== 1;
this.multiple = !selection.length this.multiple = !selection.length;
}, },
// 批量设置商品属性 // 批量设置商品属性
handleEdit() { handleEdit() {
this.$router.push({ this.$router.push({
path: "product-attr/edit", path: "product-attr/edit",
query: { query: {
ids: this.ids ids: this.ids,
} },
}); });
}, },
selectMoveAbout(val){ selectMoveAbout(val) {
if(!val.mandatory){ if (!val.mandatory) {
let index = this.form.couponIds.findIndex(i => val.couponId == i) let index = this.form.couponIds.findIndex((i) => val.couponId == i);
if(index >= 0){ if (index >= 0) {
this.$confirm(this.$t(`您确定要将商品从优惠活动${this.$l(val,'title')}中移出吗?`), this.$t('提示'), { this.$confirm(
confirmButtonText: this.$t('确定'), this.$t(
cancelButtonText:this.$t('取消') , `您确定要将商品从优惠活动${this.$l(val, "title")}中移出吗?`
type: 'warning' ),
}).then(() => { this.$t("提示"),
this.form.couponIds.splice(index,1) {
this.$forceUpdate() confirmButtonText: this.$t("确定"),
}).catch(() => { cancelButtonText: this.$t("取消"),
type: "warning",
}); }
}else { )
this.$confirm(this.$t(`您确定要将商品加入到优惠活动${this.$l(val,'title')}中吗?`), this.$t('提示'), { .then(() => {
confirmButtonText: this.$t('确定'), this.form.couponIds.splice(index, 1);
cancelButtonText:this.$t('取消') , this.$forceUpdate();
type: 'warning' })
}).then(() => { .catch(() => {});
this.form.couponIds.push(val.couponId) } else {
this.$forceUpdate() this.$confirm(
}).catch(() => { this.$t(
`您确定要将商品加入到优惠活动${this.$l(val, "title")}中吗?`
}); ),
this.$t("提示"),
{
confirmButtonText: this.$t("确定"),
cancelButtonText: this.$t("取消"),
type: "warning",
}
)
.then(() => {
this.form.couponIds.push(val.couponId);
this.$forceUpdate();
})
.catch(() => {});
} }
} }
} },
}, },
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
</style> </style>
<template> <template>
<div class="app-container"> <div class="app-container">
<doc-alert :title="$t('代码生成')" url="https://doc.iocoder.cn/new-feature/" />
<!-- 操作工作栏 --> <!-- 操作工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item :label="$t('表名称')" prop="tableName"> <el-form-item :label="$t('表名称')" prop="tableName">
<el-input v-model="queryParams.tableName" :placeholder="$t('请输入表名称')" clearable <el-input
@keyup.enter.native="handleQuery"/> v-model="queryParams.tableName"
:placeholder="$t('请输入表名称')"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('表描述')" prop="tableComment"> <el-form-item :label="$t('表描述')" prop="tableComment">
<el-input v-model="queryParams.tableComment" :placeholder="$t('请输入表描述')" clearable <el-input
@keyup.enter.native="handleQuery"/> v-model="queryParams.tableComment"
:placeholder="$t('请输入表描述')"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('创建时间')"> <el-form-item :label="$t('创建时间')">
<el-date-picker v-model="dateRange" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" <el-date-picker
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"/> v-model="dateRange"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
/>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">{{ $t('搜索') }}</el-button> <el-button type="primary" icon="el-icon-search" @click="handleQuery">{{
<el-button icon="el-icon-refresh" @click="resetQuery">{{ $t('重置') }}</el-button> $t("搜索")
}}</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">{{
$t("重置")
}}</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 操作工作栏 --> <!-- 操作工作栏 -->
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="info" plain icon="el-icon-upload" size="mini" @click="openImportTable" <el-button
v-hasPermi="['infra:codegen:create']">基于 DB 导入</el-button> type="info"
<el-button type="info" plain icon="el-icon-upload" size="mini" @click="openImportSQL" plain
v-hasPermi="['infra:codegen:create']">基于 SQL 导入</el-button> icon="el-icon-upload"
size="mini"
@click="openImportTable"
v-hasPermi="['infra:codegen:create']"
>基于 DB 导入</el-button
>
<el-button
type="info"
plain
icon="el-icon-upload"
size="mini"
@click="openImportSQL"
v-hasPermi="['infra:codegen:create']"
>基于 SQL 导入</el-button
>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row> </el-row>
<!-- 列表 --> <!-- 列表 -->
<el-table v-loading="loading" :data="tableList"> <el-table v-loading="loading" :data="tableList">
<el-table-column :label="$t('表名称')" align="center" prop="tableName" :show-overflow-tooltip="true" width="200"/> <el-table-column
<el-table-column :label="$t('表描述')" align="center" prop="tableComment" :show-overflow-tooltip="true" width="120"/> :label="$t('表名称')"
<el-table-column :label="$t('实体')" align="center" prop="className" :show-overflow-tooltip="true" width="200"/> align="center"
<el-table-column :label="$t('创建时间')" align="center" prop="createTime" width="160"> prop="tableName"
:show-overflow-tooltip="true"
width="200"
/>
<el-table-column
:label="$t('表描述')"
align="center"
prop="tableComment"
:show-overflow-tooltip="true"
width="120"
/>
<el-table-column
:label="$t('实体')"
align="center"
prop="className"
:show-overflow-tooltip="true"
width="200"
/>
<el-table-column
:label="$t('创建时间')"
align="center"
prop="createTime"
width="160"
>
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span> <span>{{ parseTime(scope.row.createTime) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('更新时间')" align="center" prop="createTime" width="160"> <el-table-column
:label="$t('更新时间')"
align="center"
prop="createTime"
width="160"
>
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.updateTime) }}</span> <span>{{ parseTime(scope.row.updateTime) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('操作')" align="center" class-name="small-padding fixed-width"> <el-table-column
:label="$t('操作')"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" size="small" icon="el-icon-view" @click="handlePreview(scope.row)" v-hasPermi="['infra:codegen:preview']">{{ $t('预览') }}</el-button> <el-button
<el-button type="text" size="small" icon="el-icon-edit" @click="handleEditTable(scope.row)" v-hasPermi="['infra:codegen:update']">{{ $t('编辑') }}</el-button> type="text"
<el-button type="text" size="small" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['infra:codegen:delete']">{{ $t('删除') }}</el-button> size="small"
<el-button type="text" size="small" icon="el-icon-refresh" @click="handleSynchDb(scope.row)" v-hasPermi="['infra:codegen:update']">{{ $t('同步') }}</el-button> icon="el-icon-view"
<el-button type="text" size="small" icon="el-icon-download" @click="handleGenTable(scope.row)" v-hasPermi="['infra:codegen:download']">{{ $t('生成代码') }}</el-button> @click="handlePreview(scope.row)"
<el-button type="text" size="small" icon="el-icon-download" @click="generateValidateCode(scope.row)">{{ $t('生成验证配置') }}</el-button> v-hasPermi="['infra:codegen:preview']"
>{{ $t("预览") }}</el-button
>
<el-button
type="text"
size="small"
icon="el-icon-edit"
@click="handleEditTable(scope.row)"
v-hasPermi="['infra:codegen:update']"
>{{ $t("编辑") }}</el-button
>
<el-button
type="text"
size="small"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['infra:codegen:delete']"
>{{ $t("删除") }}</el-button
>
<el-button
type="text"
size="small"
icon="el-icon-refresh"
@click="handleSynchDb(scope.row)"
v-hasPermi="['infra:codegen:update']"
>{{ $t("同步") }}</el-button
>
<el-button
type="text"
size="small"
icon="el-icon-download"
@click="handleGenTable(scope.row)"
v-hasPermi="['infra:codegen:download']"
>{{ $t("生成代码") }}</el-button
>
<el-button
type="text"
size="small"
icon="el-icon-download"
@click="generateValidateCode(scope.row)"
>{{ $t("生成验证配置") }}</el-button
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" @pagination="getList"/> <pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 预览界面 --> <!-- 预览界面 -->
<el-dialog :title="preview.title" :visible.sync="preview.open" width="90%" top="5vh" append-to-body class="scrollbar"> <el-dialog
:title="preview.title"
:visible.sync="preview.open"
width="90%"
top="5vh"
append-to-body
class="scrollbar"
>
<el-row> <el-row>
<el-col :span="7"> <el-col :span="7">
<el-tree :data="preview.fileTree" :expand-on-click-node="false" default-expand-all highlight-current <el-tree
@node-click="handleNodeClick"/> :data="preview.fileTree"
:expand-on-click-node="false"
default-expand-all
highlight-current
@node-click="handleNodeClick"
/>
</el-col> </el-col>
<el-col :span="17"> <el-col :span="17">
<el-tabs v-model="preview.activeName"> <el-tabs v-model="preview.activeName">
<el-tab-pane v-for="item in preview.data" :label="item.filePath.substring(item.filePath.lastIndexOf('/') + 1)" <el-tab-pane
:name="item.filePath" :key="item.filePath"> v-for="item in preview.data"
<el-link :underline="false" icon="el-icon-document-copy" v-clipboard:copy="item.code" v-clipboard:success="clipboardSuccess" style="float:right">{{ $t('复制') }}</el-link> :label="
item.filePath.substring(item.filePath.lastIndexOf('/') + 1)
"
:name="item.filePath"
:key="item.filePath"
>
<el-link
:underline="false"
icon="el-icon-document-copy"
v-clipboard:copy="item.code"
v-clipboard:success="clipboardSuccess"
style="float: right"
>{{ $t("复制") }}</el-link
>
<pre><code class="hljs" v-html="highlightedCode(item)"></code></pre> <pre><code class="hljs" v-html="highlightedCode(item)"></code></pre>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
...@@ -83,27 +229,53 @@ ...@@ -83,27 +229,53 @@
<import-table ref="import" @ok="handleQuery" /> <import-table ref="import" @ok="handleQuery" />
<!-- 基于 SQL 导入 --> <!-- 基于 SQL 导入 -->
<el-dialog :title="importSQL.title" :visible.sync="importSQL.open" width="800px" append-to-body> <el-dialog
<el-form ref="importSQLForm" :model="importSQL.form" :rules="importSQL.rules" label-width="120px"> :title="importSQL.title"
:visible.sync="importSQL.open"
width="800px"
append-to-body
>
<el-form
ref="importSQLForm"
:model="importSQL.form"
:rules="importSQL.rules"
label-width="120px"
>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="建表 SQL 语句" prop="sql"> <el-form-item label="建表 SQL 语句" prop="sql">
<el-input v-model="importSQL.form.sql" type="textarea" rows="30" style="width: 650px;" placeholder="请输入建 SQL 语句" /> <el-input
v-model="importSQL.form.sql"
type="textarea"
rows="30"
style="width: 650px"
placeholder="请输入建 SQL 语句"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitImportSQLForm">{{ $t('确 定') }}</el-button> <el-button type="primary" @click="submitImportSQLForm">{{
<el-button @click="cancel">{{ $t('取 消') }}</el-button> $t("确 定")
}}</el-button>
<el-button @click="cancel">{{ $t("取 消") }}</el-button>
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
import {getCodegenDetail, getCodegenTablePage, previewCodegen, downloadCodegen, deleteCodegen, import {
syncCodegenFromDB, syncCodegenFromSQL, createCodegenListFromSQL } from "@/api/infra/codegen"; getCodegenDetail,
getCodegenTablePage,
previewCodegen,
downloadCodegen,
deleteCodegen,
syncCodegenFromDB,
syncCodegenFromSQL,
createCodegenListFromSQL,
} from "@/api/infra/codegen";
import importTable from "./importTable"; import importTable from "./importTable";
// 代码高亮插件 // 代码高亮插件
...@@ -113,7 +285,10 @@ hljs.registerLanguage("java", require("highlight.js/lib/languages/java")); ...@@ -113,7 +285,10 @@ hljs.registerLanguage("java", require("highlight.js/lib/languages/java"));
hljs.registerLanguage("xml", require("highlight.js/lib/languages/xml")); hljs.registerLanguage("xml", require("highlight.js/lib/languages/xml"));
hljs.registerLanguage("html", require("highlight.js/lib/languages/xml")); hljs.registerLanguage("html", require("highlight.js/lib/languages/xml"));
hljs.registerLanguage("vue", require("highlight.js/lib/languages/xml")); hljs.registerLanguage("vue", require("highlight.js/lib/languages/xml"));
hljs.registerLanguage("javascript", require("highlight.js/lib/languages/javascript")); hljs.registerLanguage(
"javascript",
require("highlight.js/lib/languages/javascript")
);
hljs.registerLanguage("sql", require("highlight.js/lib/languages/sql")); hljs.registerLanguage("sql", require("highlight.js/lib/languages/sql"));
export default { export default {
...@@ -140,7 +315,7 @@ export default { ...@@ -140,7 +315,7 @@ export default {
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
tableName: undefined, tableName: undefined,
tableComment: undefined tableComment: undefined,
}, },
// 预览参数 // 预览参数
preview: { preview: {
...@@ -154,13 +329,11 @@ export default { ...@@ -154,13 +329,11 @@ export default {
importSQL: { importSQL: {
open: false, open: false,
title: "", title: "",
form: { form: {},
},
rules: { rules: {
sql: [{ required: true, message: "SQL 不能为空", trigger: "blur" }] sql: [{ required: true, message: "SQL 不能为空", trigger: "blur" }],
} },
} },
}; };
}, },
created() { created() {
...@@ -177,15 +350,20 @@ export default { ...@@ -177,15 +350,20 @@ export default {
/** 查询表集合 */ /** 查询表集合 */
getList() { getList() {
this.loading = true; this.loading = true;
getCodegenTablePage(this.addDateRange(this.queryParams, [ getCodegenTablePage(
this.dateRange[0] ? this.dateRange[0] + ' 00:00:00' : undefined, this.addDateRange(
this.dateRange[1] ? this.dateRange[1] + ' 23:59:59' : undefined, this.queryParams,
], 'CreateTime')).then(response => { [
this.tableList = response.data.list; this.dateRange[0] ? this.dateRange[0] + " 00:00:00" : undefined,
this.total = response.data.total; this.dateRange[1] ? this.dateRange[1] + " 23:59:59" : undefined,
this.loading = false; ],
} "CreateTime"
); )
).then((response) => {
this.tableList = response.data.list;
this.total = response.data.total;
this.loading = false;
});
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
...@@ -194,9 +372,9 @@ export default { ...@@ -194,9 +372,9 @@ export default {
}, },
/** 生成代码操作 */ /** 生成代码操作 */
handleGenTable(row) { handleGenTable(row) {
downloadCodegen(row.id).then(response => { downloadCodegen(row.id).then((response) => {
this.$download.zip(response, 'codegen-' + row.tableName + '.zip'); this.$download.zip(response, "codegen-" + row.tableName + ".zip");
}) });
}, },
/** 同步数据库操作 */ /** 同步数据库操作 */
handleSynchDb(row) { handleSynchDb(row) {
...@@ -208,11 +386,15 @@ export default { ...@@ -208,11 +386,15 @@ export default {
} }
// 基于 DB 同步 // 基于 DB 同步
const tableName = row.tableName; const tableName = row.tableName;
this.$modal.confirm('确认要强制同步"' + tableName + '"表结构吗?').then(function() { this.$modal
.confirm('确认要强制同步"' + tableName + '"表结构吗?')
.then(function () {
return syncCodegenFromDB(row.id); return syncCodegenFromDB(row.id);
}).then(() => { })
.then(() => {
this.$modal.msgSuccess("同步成功"); this.$modal.msgSuccess("同步成功");
}).catch(() => {}); })
.catch(() => {});
}, },
/** 打开导入表弹窗 */ /** 打开导入表弹窗 */
openImportTable() { openImportTable() {
...@@ -230,11 +412,16 @@ export default { ...@@ -230,11 +412,16 @@ export default {
}, },
/** 预览按钮 */ /** 预览按钮 */
handlePreview(row) { handlePreview(row) {
previewCodegen(row.id).then(response => { previewCodegen(row.id).then((response) => {
this.preview.data = response.data; this.preview.data = response.data;
let files = this.handleFiles(response.data); let files = this.handleFiles(response.data);
this.preview.fileTree = this.handleTree(files, "id", "parentId", "children", this.preview.fileTree = this.handleTree(
"/"); // "/" 为根节点 files,
"id",
"parentId",
"children",
"/"
); // "/" 为根节点
// console.log(this.preview.fileTree) // console.log(this.preview.fileTree)
this.preview.activeName = response.data[0].filePath; this.preview.activeName = response.data[0].filePath;
this.preview.open = true; this.preview.open = true;
...@@ -244,12 +431,14 @@ export default { ...@@ -244,12 +431,14 @@ export default {
highlightedCode(item) { highlightedCode(item) {
// const vmName = key.substring(key.lastIndexOf("/") + 1, key.indexOf(".vm")); // const vmName = key.substring(key.lastIndexOf("/") + 1, key.indexOf(".vm"));
// var language = vmName.substring(vmName.indexOf(".") + 1, vmName.length); // var language = vmName.substring(vmName.indexOf(".") + 1, vmName.length);
var language = item.filePath.substring(item.filePath.lastIndexOf(".") + 1); var language = item.filePath.substring(
item.filePath.lastIndexOf(".") + 1
);
const result = hljs.highlight(language, item.code || "", true); const result = hljs.highlight(language, item.code || "", true);
return result.value || '&nbsp;'; return result.value || "&nbsp;";
}, },
/** 复制代码成功 */ /** 复制代码成功 */
clipboardSuccess(){ clipboardSuccess() {
this.$modal.msgSuccess("复制成功"); this.$modal.msgSuccess("复制成功");
}, },
/** 生成 files 目录 **/ /** 生成 files 目录 **/
...@@ -258,14 +447,14 @@ export default { ...@@ -258,14 +447,14 @@ export default {
let files = []; let files = [];
// 遍历每个元素 // 遍历每个元素
for (const data of datas) { for (const data of datas) {
let paths = data.filePath.split('/'); let paths = data.filePath.split("/");
let fullPath = ''; // 从头开始的路径,用于生成 id let fullPath = ""; // 从头开始的路径,用于生成 id
// 特殊处理 java 文件 // 特殊处理 java 文件
if (paths[paths.length - 1].indexOf('.java') >= 0) { if (paths[paths.length - 1].indexOf(".java") >= 0) {
let newPaths = []; let newPaths = [];
for (let i = 0; i < paths.length; i++) { for (let i = 0; i < paths.length; i++) {
let path = paths[i]; let path = paths[i];
if (path !== 'java') { if (path !== "java") {
newPaths.push(path); newPaths.push(path);
continue; continue;
} }
...@@ -274,17 +463,19 @@ export default { ...@@ -274,17 +463,19 @@ export default {
let tmp = undefined; let tmp = undefined;
while (i < paths.length) { while (i < paths.length) {
path = paths[i + 1]; path = paths[i + 1];
if (path === 'controller' if (
|| path === 'convert' path === "controller" ||
|| path === 'dal' path === "convert" ||
|| path === 'enums' path === "dal" ||
|| path === 'service' path === "enums" ||
|| path === 'vo' // 下面三个,主要是兜底。可能考虑到有人改了包结构 path === "service" ||
|| path === 'mysql' path === "vo" || // 下面三个,主要是兜底。可能考虑到有人改了包结构
|| path === 'dataobject') { path === "mysql" ||
path === "dataobject"
) {
break; break;
} }
tmp = tmp ? tmp + '.' + path : path; tmp = tmp ? tmp + "." + path : path;
i++; i++;
} }
if (tmp) { if (tmp) {
...@@ -298,7 +489,10 @@ export default { ...@@ -298,7 +489,10 @@ export default {
// 已经添加到 files 中,则跳过 // 已经添加到 files 中,则跳过
let oldFullPath = fullPath; let oldFullPath = fullPath;
// 下面的 replaceAll 的原因,是因为上面包处理了,导致和 tabs 不匹配,所以 replaceAll 下 // 下面的 replaceAll 的原因,是因为上面包处理了,导致和 tabs 不匹配,所以 replaceAll 下
fullPath = fullPath.length === 0 ? paths[i] : fullPath.replaceAll('.', '/') + '/' + paths[i]; fullPath =
fullPath.length === 0
? paths[i]
: fullPath.replaceAll(".", "/") + "/" + paths[i];
if (exists[fullPath]) { if (exists[fullPath]) {
continue; continue;
} }
...@@ -307,7 +501,7 @@ export default { ...@@ -307,7 +501,7 @@ export default {
files.push({ files.push({
id: fullPath, id: fullPath,
label: paths[i], label: paths[i],
parentId: oldFullPath || '/' // "/" 为根节点 parentId: oldFullPath || "/", // "/" 为根节点
}); });
} }
} }
...@@ -329,12 +523,16 @@ export default { ...@@ -329,12 +523,16 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const tableIds = row.id; const tableIds = row.id;
this.$modal.confirm('是否确认删除表名称为"' + row.tableName + '"的数据项?').then(function() { this.$modal
.confirm('是否确认删除表名称为"' + row.tableName + '"的数据项?')
.then(function () {
return deleteCodegen(tableIds); return deleteCodegen(tableIds);
}).then(() => { })
.then(() => {
this.getList(); this.getList();
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); })
.catch(() => {});
}, },
// 取消按钮 // 取消按钮
cancel() { cancel() {
...@@ -351,14 +549,14 @@ export default { ...@@ -351,14 +549,14 @@ export default {
}, },
// 提交 import SQL 表单 // 提交 import SQL 表单
submitImportSQLForm() { submitImportSQLForm() {
this.$refs["importSQLForm"].validate(valid => { this.$refs["importSQLForm"].validate((valid) => {
if (!valid) { if (!valid) {
return; return;
} }
// 修改的提交 // 修改的提交
let form = this.importSQL.form; let form = this.importSQL.form;
if (form.tableId != null) { if (form.tableId != null) {
syncCodegenFromSQL(form.tableId, form.sql).then(response => { syncCodegenFromSQL(form.tableId, form.sql).then((response) => {
this.$modal.msgSuccess("同步成功"); this.$modal.msgSuccess("同步成功");
this.importSQL.open = false; this.importSQL.open = false;
this.getList(); this.getList();
...@@ -366,41 +564,45 @@ export default { ...@@ -366,41 +564,45 @@ export default {
return; return;
} }
// 添加的提交 // 添加的提交
createCodegenListFromSQL(form).then(response => { createCodegenListFromSQL(form).then((response) => {
this.$modal.msgSuccess("导入成功"); this.$modal.msgSuccess("导入成功");
this.importSQL.open = false; this.importSQL.open = false;
this.getList(); this.getList();
}); });
}); });
}, },
generateValidateCode(row){ generateValidateCode(row) {
let l = this.$loading() let l = this.$loading();
getCodegenDetail(row.id).then(res => { getCodegenDetail(row.id)
let rules = {} .then((res) => {
res.data.columns.forEach(item => { let rules = {};
let rule = {trigger: 'blur'} res.data.columns.forEach((item) => {
if(!item.nullable){ let rule = { trigger: "blur" };
rule.required = true if (!item.nullable) {
rule.message = this.$t('不能为空') rule.required = true;
} rule.message = this.$t("不能为空");
if(['int', 'tinyint', 'bigint'].indexOf(item.columnType)){ }
rule.type = 'integer' if (["int", "tinyint", "bigint"].indexOf(item.columnType)) {
} rule.type = "integer";
if(item.columnType.indexOf('decimal') === 0){ }
rule.type = 'decimal' if (item.columnType.indexOf("decimal") === 0) {
} rule.type = "decimal";
if(item.columnType == 'datetime'){ }
rule.type = 'date' if (item.columnType == "datetime") {
} rule.type = "date";
rules[item.javaField] = [rule] }
rules[item.javaField] = [rule];
});
console.log(
row.tableComment + this.$t("校验规则"),
JSON.stringify(rules)
);
this.$message("规则已生成,打开控制台查看");
}) })
console.log(row.tableComment + this.$t('校验规则'), JSON.stringify(rules)) .finally((res) => {
this.$message('规则已生成,打开控制台查看') l.close();
}) });
.finally(res => {
l.close()
})
}, },
} },
}; };
</script> </script>
<template> <template>
<div class="app-container"> <div class="app-container">
<doc-alert :title="$t('上传下载')" url="https://doc.iocoder.cn/file/" />
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item :label="$t('文件路径')" prop="path"> <el-form-item :label="$t('文件路径')" prop="path">
<el-input v-model="queryParams.path" :placeholder="$t('请输入文件路径')" clearable @keyup.enter.native="handleQuery"/> <el-input
v-model="queryParams.path"
:placeholder="$t('请输入文件路径')"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('创建时间')"> <el-form-item :label="$t('创建时间')">
<el-date-picker v-model="dateRangeCreateTime" style="width: 240px" value-format="yyyy-MM-dd" <el-date-picker
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" /> v-model="dateRangeCreateTime"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
/>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">{{ $t('搜索') }}</el-button> <el-button type="primary" icon="el-icon-search" @click="handleQuery">{{
<el-button icon="el-icon-refresh" @click="resetQuery">{{ $t('重置') }}</el-button> $t("搜索")
}}</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">{{
$t("重置")
}}</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 操作工具栏 --> <!-- 操作工具栏 -->
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">{{ $t('上传文件') }}</el-button> <el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>{{ $t("上传文件") }}</el-button
>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row> </el-row>
<!-- 列表 --> <!-- 列表 -->
<el-table v-loading="loading" :data="list"> <el-table v-loading="loading" :data="list">
<el-table-column :label="$t('文件名')" align="center" prop="path" /> <el-table-column :label="$t('文件名')" align="center" prop="path" />
<el-table-column label="URL" align="center" prop="url" /> <el-table-column label="URL" align="center" prop="url" />
<el-table-column :label="$t('文件大小')" align="center" prop="size" width="120" :formatter="sizeFormat" /> <el-table-column
<el-table-column :label="$t('文件类型')" align="center" prop="type" width="80" /> :label="$t('文件大小')"
<!-- <el-table-column :label="$t('文件内容')" align="center" prop="content">--> align="center"
<!-- <template slot-scope="scope">--> prop="size"
<!-- <img v-if="scope.row.type === 'jpg' || scope.row.type === 'png' || scope.row.type === 'gif'"--> width="120"
<!-- width="200px" :src="getFileUrl + scope.row.id">--> :formatter="sizeFormat"
<!-- <i v-else>{{ $t('非图片,无法预览') }}</i>--> />
<!-- </template>--> <el-table-column
<!-- </el-table-column>--> :label="$t('文件类型')"
<el-table-column :label="$t('上传时间')" align="center" prop="createTime" width="180"> align="center"
prop="type"
width="80"
/>
<!-- <el-table-column :label="$t('文件内容')" align="center" prop="content">-->
<!-- <template slot-scope="scope">-->
<!-- <img v-if="scope.row.type === 'jpg' || scope.row.type === 'png' || scope.row.type === 'gif'"-->
<!-- width="200px" :src="getFileUrl + scope.row.id">-->
<!-- <i v-else>{{ $t('非图片,无法预览') }}</i>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column
:label="$t('上传时间')"
align="center"
prop="createTime"
width="180"
>
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span> <span>{{ parseTime(scope.row.createTime) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('操作')" align="center" class-name="small-padding fixed-width" width="100"> <el-table-column
:label="$t('操作')"
align="center"
class-name="small-padding fixed-width"
width="100"
>
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" <el-button
v-hasPermi="['infra:file:delete']">{{ $t('删除') }}</el-button> size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['infra:file:delete']"
>{{ $t("删除") }}</el-button
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 分页组件 --> <!-- 分页组件 -->
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" <pagination
@pagination="getList"/> v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 对话框(添加 / 修改) --> <!-- 对话框(添加 / 修改) -->
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body> <el-dialog
<el-upload ref="upload" :limit="1" accept=".jpg, .png, .gif,.apk" :auto-upload="false" drag :title="upload.title"
:headers="upload.headers" :action="upload.url" :data="upload.data" :disabled="upload.isUploading" :visible.sync="upload.open"
:on-change="handleFileChange" width="400px"
:on-progress="handleFileUploadProgress" append-to-body
:on-success="handleFileSuccess"> >
<el-upload
ref="upload"
:limit="1"
accept=".jpg, .png, .gif,.apk"
:auto-upload="false"
drag
:headers="upload.headers"
:action="upload.url"
:data="upload.data"
:disabled="upload.isUploading"
:on-change="handleFileChange"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
>
<i class="el-icon-upload"></i> <i class="el-icon-upload"></i>
<div class="el-upload__text">{{ $t('将文件拖到此处,或') }}<em>{{ $t('点击上传') }}</em> <div class="el-upload__text">
{{ $t("将文件拖到此处,或") }}<em>{{ $t("点击上传") }}</em>
</div>
<div class="el-upload__tip" style="color: red" slot="tip">
提示:仅允许导入 jpg、png、gif 格式文件!
</div> </div>
<div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入 jpg、png、gif 格式文件!</div>
</el-upload> </el-upload>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm">{{ $t('确 定') }}</el-button> <el-button type="primary" @click="submitFileForm">{{
<el-button @click="upload.open = false">{{ $t('取 消') }}</el-button> $t("确 定")
}}</el-button>
<el-button @click="upload.open = false">{{ $t("取 消") }}</el-button>
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { deleteFile, getFilePage } from "@/api/infra/file"; import { deleteFile, getFilePage } from "@/api/infra/file";
import {getToken} from "@/utils/auth"; import { getToken } from "@/utils/auth";
export default { export default {
name: "File", name: "File",
data() { data() {
return { return {
getFileUrl: process.env.VUE_APP_BASE_API + '/admin-api/infra/file/get/', getFileUrl: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/get/",
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 显示搜索条件 // 显示搜索条件
...@@ -108,7 +190,7 @@ export default { ...@@ -108,7 +190,7 @@ export default {
isUploading: false, // 是否禁用上传 isUploading: false, // 是否禁用上传
url: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/upload", // 请求地址 url: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/upload", // 请求地址
headers: { Authorization: "Bearer " + getToken() }, // 设置上传的请求头部 headers: { Authorization: "Bearer " + getToken() }, // 设置上传的请求头部
data: {} // 上传的额外数据,用于文件名 data: {}, // 上传的额外数据,用于文件名
}, },
}; };
}, },
...@@ -120,10 +202,10 @@ export default { ...@@ -120,10 +202,10 @@ export default {
getList() { getList() {
this.loading = true; this.loading = true;
// 处理查询参数 // 处理查询参数
let params = {...this.queryParams}; let params = { ...this.queryParams };
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime'); this.addBeginAndEndTime(params, this.dateRangeCreateTime, "createTime");
// 执行查询 // 执行查询
getFilePage(params).then(response => { getFilePage(params).then((response) => {
this.list = response.data.list; this.list = response.data.list;
this.total = response.data.total; this.total = response.data.total;
this.loading = false; this.loading = false;
...@@ -182,22 +264,26 @@ export default { ...@@ -182,22 +264,26 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const id = row.id; const id = row.id;
this.$modal.confirm('是否确认删除文件编号为"' + id + '"的数据项?').then(function() { this.$modal
return deleteFile(id); .confirm('是否确认删除文件编号为"' + id + '"的数据项?')
}).then(() => { .then(function () {
this.getList(); return deleteFile(id);
this.$modal.msgSuccess("删除成功"); })
}).catch(() => {}); .then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
})
.catch(() => {});
}, },
// 用户昵称展示 // 用户昵称展示
sizeFormat(row, column) { sizeFormat(row, column) {
const unitArr = ["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"]; const unitArr = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
const srcSize = parseFloat(row.size); const srcSize = parseFloat(row.size);
const index = Math.floor(Math.log(srcSize) / Math.log(1024)); const index = Math.floor(Math.log(srcSize) / Math.log(1024));
let size =srcSize/Math.pow(1024,index); let size = srcSize / Math.pow(1024, index);
size = size.toFixed(2);//保留的小数位数 size = size.toFixed(2); //保留的小数位数
return size + ' ' + unitArr[index]; return size + " " + unitArr[index];
}, },
} },
}; };
</script> </script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment