| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424 |
- <template>
- <div style="display: inline-block; overflow: auto">
- <div>
- <div v-if="showFlagBtn">
- <el-radio v-model="mode" label="view">预览模式</el-radio>
- <el-radio v-model="mode" label="edit">编辑模式</el-radio>
- </div>
- <div style="border: 2px solid pink; display: inline-block;margin-right: 5px;" v-for="(item, index) in cardItemList" :key="item.cardItemId">
- <el-row :gutter="12" style="padding-top: 5px">
- <el-col :span="12">
- <el-card :body-style="{ padding: '0px' }">
- <div style="padding: 3px; text-align: center">
- <span>正面</span>
- </div>
- <el-image style="width: 100px; height: 100px;" v-if="mode=='view'" :src="resourcesUrl + item.frontPic" @click="previewPic(item, item.frontPic, item.prodName, 'front')"/>
- <el-upload v-else
- class="avatar-uploader"
- accept="image/jpg"
- :before-upload="(file, fileList)=>handleBeforeUpload(file, fileList,item)"
- :action="$http.adornUrl('/admin/file/simpleUpload')"
- :headers="{Authorization: $cookie.get('Authorization_vs'),locale:lang}"
- :on-success="(res,file)=>{onFrontUploadSuccess(item,res,file)}"
- :show-file-list="false">
- <img v-if="item.frontPic" :src="resourcesUrl + item.frontPic" class="avatar">
- <i v-else class="el-icon-plus avatar-uploader-icon"></i>
- </el-upload>
- </el-card>
- </el-col>
- <el-col :span="12">
- <el-card :body-style="{ padding: '0px' }">
- <div style="padding: 3px; text-align: center">
- <span>背面</span>
- </div>
- <el-image v-if="mode=='view'" :src="resourcesUrl + item.backPic" style="width: 100px; height: 100px;" @click="previewPic(item, item.backPic, item.prodName, 'back')"/>
- <el-upload v-else
- class="avatar-uploader"
- :before-upload="(file, fileList)=>handleBeforeUpload(file, fileList,item)"
- :action="$http.adornUrl('/admin/file/simpleUpload')"
- :headers="{Authorization: $cookie.get('Authorization_vs'),locale:lang}"
- :on-success="(res,file)=>{onBackUploadSuccess(item,res,file)}"
- :show-file-list="false">
- <img v-if="item.backPic" :src="resourcesUrl + item.backPic" class="avatar">
- <i v-else class="el-icon-plus avatar-uploader-icon"></i>
- </el-upload>
- </el-card>
- </el-col>
- </el-row>
- <el-row style="width: 210px; height: 30px; text-align: center ;color: red; font-weight: bold">
- <span v-if="showFlagBtn">
- <el-button v-if="item.flag==0 && mode=='view'" type="success" size="mini" style="margin-right: 20px" @click="handleFlag(item, index)">待标记</el-button>
- <el-button v-if="item.flag==1 && mode=='view'" type="warning" size="mini" style="margin-right: 5px" @click="handleFlag(item, index)">已标记</el-button>
- <el-button v-if="mode=='view'" type="text" size="mini" @click="openOrgPicForm(item, index)">原图</el-button>
- <el-button v-if="item.prodName.indexOf('语音') !== -1 && mode=='view'" type="text" size="mini" @click="openYYForm(item, index)">查看语音</el-button>
- <el-button v-if="mode==='edit'" type="primary" size="mini" style="margin-right: 5px" @click="addOrUpdateCardItem(item)">保存</el-button>
- <el-button v-if="mode==='edit' && item.cardItemId" type="danger" size="mini" style="margin-right: 5px" @click="deleteCardItem(item, index)">删除</el-button>
- </span>
- </el-row>
- <el-row style="width: 210px; height: 30px; text-align: center ;color: red; font-weight: bold">
- <span>No.{{index + 1}}</span>
- <span v-if="showFlagBtn" style="color: white">
- __________
- </span>
- <span>X</span>
- <span v-if="mode=='view'">{{item.prodCount}}</span>
- <el-input type="number" size="mini" style="width: 60px;height: 20px" v-if="mode=='edit'" v-model="item.prodCount"></el-input>
- </el-row>
- </div>
- <div v-if="mode=='edit'" style="display: inline-block;">
- <el-button
- circle
- icon="el-icon-plus"
- @click="addCardItem">
- </el-button>
- </div>
- </div>
- <CanvasPreview v-if= "previewPicDialogVisible" ref="canvasPreviewRef"></CanvasPreview>
- <YuyinPreview ref="yuYinPreviewRef"></YuyinPreview>
- <OrgPicPreview ref="orgPicPreviewRef"></OrgPicPreview>
- </div>
- </template>
- <script>
- import CanvasPreview from "../canvas-preview/index";
- import YuyinPreview from "../yuyin-preview/index";
- import OrgPicPreview from "../org-pic-preview/index";
- export default {
- components: {CanvasPreview, YuyinPreview,OrgPicPreview},
- data () {
- return {
- lang: localStorage.getItem('lang') || 'zh_CN',
- cardItemList:[],
- previewPicUrl: null,
- prodType: null,
- previewPicDialogVisible: false,
- previewYuyinDialogVisible: false,
- side:null,
- resourcesUrl: process.env.VUE_APP_RESOURCES_URL,
- mode: 'view',
- previewWidth: 0,
- previewHeight: 0,
- bloodWidth: 0
- }
- },
- props: {
- orderItem: {
- default: null,
- type: Object
- },
- showFlagBtn:{
- default: true,
- type: Boolean
- }
- },
- created() {
- this.$nextTick(() => {
- this.getDataList();
- })
- },
- methods: {
- openYYForm(item, index){
- this.$nextTick(() =>{
- this.$refs.yuYinPreviewRef.init(item)
- })
- },
- openOrgPicForm(item, index){
- this.$nextTick(() =>{
- this.$refs.orgPicPreviewRef.init(item)
- })
- },
- previewLoad(event){
- this.previewWidth = event.srcElement.clientWidth;
- this.previewHeight = event.srcElement.clientHeight;
- },
- handleBeforeUpload(file, fileList, item){
- let fileType = file.type;
- let isJpg = fileType === 'image/jpg' || fileType === 'image/jpeg';
- if(!isJpg){
- this.$message.error("只允许上传JPG格式的图片");
- return false;
- }
- let isSize = true;
- //如果当前是编辑的小卡,就需要判断是否符合尺寸
- let width = 709;
- let height = 1087;
- let prodName = item.prodName;
- isSize = new Promise(function(resolve, reject) {
- if(prodName.indexOf("小卡") !== -1 || prodName.indexOf("影像级花式拍立得") !== -1){
- width = 709;
- height = 1087;
- }else if(prodName.indexOf("票根") !== -1){
- width = 780;
- height = 1489;
- }else if(prodName.indexOf("直拍封面") !== -1){
- width = 732;
- height = 1252;
- }else if(prodName.indexOf("二宫格") !== -1){
- width = 1252;
- height = 732;
- }else if(prodName.indexOf("明信片") !== -1){
- width = 1229;
- height = 1796;
- }else if(prodName.indexOf("三宫格") !== -1){
- width = 673;
- height = 1547;
- }else if(prodName.indexOf("书签") !== -1){
- width = 638;
- height = 1796;
- }else if(prodName.indexOf("小方卡") !== -1){
- width = 673;
- height = 673;
- }else if(prodName.indexOf("方卡") !== -1){
- width = 1229;
- height = 1229;
- }else if(prodName.indexOf("手幅") !== -1){
- width = 1252;
- height = 3614;
- }else if(prodName.indexOf("毛绒徽章") !== -1){
- width = 827;
- height = 827;
- }else if(prodName.indexOf("圆形徽章") !== -1){
- width = 850;
- height = 850;
- }else if(prodName.indexOf("手幅") !== -1){
- width = 1252;
- height = 3614;
- }else if(prodName.indexOf("4寸典藏级花式拍立得") !== -1){
- width = 921;
- height = 1087;
- }else if(prodName.indexOf("5寸典藏级花式拍立得") !== -1){
- width = 1346;
- height = 1087;
- }else if(prodName.indexOf("长方形贴纸") !== -1){
- width = 780;
- height = 1134;
- }else if(prodName.indexOf("方形贴纸") !== -1){
- width = 662;
- height = 662;
- }else if(prodName.indexOf("撕拉") !== -1){
- width = 768;
- height = 768;
- }
- let _URL = window.URL || window.webkitURL;
- let img = new Image();
- img.onload = function() {
- let valid = img.width == width && img.height == height;
- valid ? resolve() : reject();
- };
- img.src = _URL.createObjectURL(file);
- }).then(
- () => {
- return file;
- },
- () => {
- this.$message.error("上传的图片宽高必须是" + width + "*" + height);
- return Promise.reject();
- }
- );
- return isJpg && isSize;
- },
- deleteCardItem(item, index){
- this.$confirm('确定要删除吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.$http({
- url: this.$http.adornUrl('/prod/orderCardItem/' + item.cardItemId),
- method: 'delete',
- }).then(({ data }) =>{
- if(data){
- this.$delete(this.cardItemList, index);
- this.$message.success("删除成功");
- }else{
- this.$message.error("删除失败");
- }
- })
- });
- },
- addOrUpdateCardItem(item){
- this.$confirm('确定要更新吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.$http({
- url: this.$http.adornUrl('/prod/orderCardItem/saveOrUpdate'),
- method: 'post',
- data: this.$http.adornData(item)
- }).then(({ data }) =>{
- if(data){
- this.$set(item, 'cardItemId', data.cardItemId);
- this.$message.success("保存成功");
- }else{
- this.$message.error("保存失败");
- }
- })
- });
- },
- onFrontUploadSuccess (item, response, file) {
- this.$set(item,'frontPic',response.filePath);
- this.$forceUpdate()
- },
- onBackUploadSuccess (item, response, file) {
- this.$set(item,'backPic',response.filePath);
- this.$forceUpdate()
- },
- addCardItem(){
- if(this.cardItemList.length > 0){
- let item = this.cardItemList[0];
- let newItem = {orderNumber: item.orderNumber, orderItemId: this.orderItem.orderItemId, prodName: item.prodName, skuName: item.skuName, flag: 0, prodCount: 1 }
- this.cardItemList.push(newItem);
- }else{
- let newItem = {orderNumber: this.orderItem.orderNumber, orderItemId: this.orderItem.orderItemId, prodName: this.orderItem.prodName, skuName: this.orderItem.skuName, flag: 0, prodCount: 1}
- this.cardItemList.push(newItem);
- }
- },
- handleFlag(item, index){
- let fl = item.flag == 1? 0 : 1
- this.$http({
- url: this.$http.adornUrl('/prod/orderCardItem/flag'),
- method: 'post',
- data: this.$http.adornParams(
- Object.assign({
- cardItemId: item.cardItemId,
- flag: fl
- },
- )
- )
- }).then(({data}) => {
- if(data){
- this.$message({
- message: "标记完成",
- type: 'success',
- });
- this.cardItemList[index].flag = fl;
- }else{
- this.$message({
- message: "标记失败",
- type: 'error',
- })
- }
- })
- },
- previewPic(cardItem, picUrl, prodName, side){
- this.previewPicUrl = this.resourcesUrl + picUrl
- this.previewPicDialogVisible = true;
- this.side = side;
- if(prodName.indexOf('小卡') != -1){
- this.prodType = '小卡';
- } else if(prodName.indexOf('3寸花式拍立得') != -1){
- this.prodType = '3寸花式拍立得';
- }else if(prodName.indexOf('4寸典藏级花式拍立得') != -1){
- this.prodType = '4寸典藏级花式拍立得';
- }else if(prodName.indexOf('5寸典藏级花式拍立得') != -1){
- this.prodType = '5寸典藏级花式拍立得';
- }else if(prodName.indexOf('直拍封面') != -1){
- this.prodType = '直拍封面';
- }else if(prodName.indexOf('票根') != -1){
- this.prodType = '票根';
- }else if(prodName.indexOf('明信片') != -1){
- this.prodType = '明信片';
- }else if(prodName.indexOf('小方卡') != -1){
- this.prodType = '小方卡';
- }else if(prodName.indexOf('方卡') != -1){
- this.prodType = '方卡';
- }else if(prodName.indexOf('四宫格书签') != -1){
- this.prodType = '四宫格书签';
- }else if(prodName.indexOf('徽章') != -1){
- this.prodType = '徽章';
- }else if(prodName.indexOf('手幅') != -1){
- this.prodType = '手幅';
- }else if(prodName.indexOf('毛绒徽章') != -1){
- this.prodType = '毛绒徽章';
- }else if(prodName.indexOf('三宫格') != -1){
- this.prodType = '三宫格';
- }else if(prodName.indexOf('长方形贴纸') != -1){
- this.prodType = '长方形贴纸';
- }else if(prodName.indexOf('方形贴纸') != -1){
- this.prodType = '方形贴纸';
- }else if(prodName.indexOf('二宫格') != -1){
- this.prodType = '二宫格';
- }else if(prodName.indexOf('撕拉') != -1){
- this.prodType = '撕拉';
- }
- this.$nextTick(() =>{
- this.$refs.canvasPreviewRef.init(cardItem, this.resourcesUrl + picUrl, this.prodType, side)
- })
- },
- getDataList () {
- this.$http({
- url: this.$http.adornUrl('/prod/orderCardItem/page'),
- method: 'get',
- params: this.$http.adornParams(
- Object.assign({
- size: 300,
- orderNumber: this.orderItem.orderNumber,
- orderItemId: this.orderItem.orderItemId,
- },
- )
- )
- }).then(({data}) => {
- this.cardItemList = data.records;
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .previewClass{
- position:absolute;
- border-style:solid;
- border-color:red;
- opacity:0.3;
- z-index:3;
- }
- #cardBottom{
- position:absolute;
- z-index:1;
- }
- .avatar-uploader .el-upload {
- border: 1px dashed #d9d9d9;
- border-radius: 6px;
- cursor: pointer;
- position: relative;
- overflow: hidden;
- }
- .avatar-uploader .el-upload:hover {
- border-color: #409EFF;
- }
- .avatar-uploader-icon {
- font-size: 28px;
- color: #8c939d;
- width: 100px;
- height: 100px;
- line-height: 100px;
- text-align: center;
- }
- .avatar {
- width: 100px;
- height: 100px;
- display: block;
- }
- /* .prods-select-body {
- height: 600px;
- overflow: auto;
- border-top: 1px solid #eeeeee;
- border-right: 1px solid #eeeeee;
- border-bottom: 1px solid #eeeeee;
- } */
- .brand-select-pop {
- & ::v-deep .el-dialog__body {
- padding-top: 20px;
- padding-bottom: 20px;
- }
- .main-container {
- margin: 0;
- .pagination {
- text-align: right;
- }
- }
- }
- </style>
|