index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. <template>
  2. <div style="display: inline-block; overflow: auto">
  3. <div>
  4. <div v-if="showFlagBtn">
  5. <el-radio v-model="mode" label="view">预览模式</el-radio>
  6. <el-radio v-model="mode" label="edit">编辑模式</el-radio>
  7. </div>
  8. <div style="border: 2px solid pink; display: inline-block;margin-right: 5px;" v-for="(item, index) in cardItemList" :key="item.cardItemId">
  9. <el-row :gutter="12" style="padding-top: 5px">
  10. <el-col :span="12">
  11. <el-card :body-style="{ padding: '0px' }">
  12. <div style="padding: 3px; text-align: center">
  13. <span>正面</span>
  14. </div>
  15. <el-image style="width: 100px; height: 100px;" v-if="mode=='view'" :src="resourcesUrl + item.frontPic" @click="previewPic(item, item.frontPic, item.prodName, 'front')"/>
  16. <el-upload v-else
  17. class="avatar-uploader"
  18. accept="image/jpg"
  19. :before-upload="(file, fileList)=>handleBeforeUpload(file, fileList,item)"
  20. :action="$http.adornUrl('/admin/file/simpleUpload')"
  21. :headers="{Authorization: $cookie.get('Authorization_vs'),locale:lang}"
  22. :on-success="(res,file)=>{onFrontUploadSuccess(item,res,file)}"
  23. :show-file-list="false">
  24. <img v-if="item.frontPic" :src="resourcesUrl + item.frontPic" class="avatar">
  25. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  26. </el-upload>
  27. </el-card>
  28. </el-col>
  29. <el-col :span="12">
  30. <el-card :body-style="{ padding: '0px' }">
  31. <div style="padding: 3px; text-align: center">
  32. <span>背面</span>
  33. </div>
  34. <el-image v-if="mode=='view'" :src="resourcesUrl + item.backPic" style="width: 100px; height: 100px;" @click="previewPic(item, item.backPic, item.prodName, 'back')"/>
  35. <el-upload v-else
  36. class="avatar-uploader"
  37. :before-upload="(file, fileList)=>handleBeforeUpload(file, fileList,item)"
  38. :action="$http.adornUrl('/admin/file/simpleUpload')"
  39. :headers="{Authorization: $cookie.get('Authorization_vs'),locale:lang}"
  40. :on-success="(res,file)=>{onBackUploadSuccess(item,res,file)}"
  41. :show-file-list="false">
  42. <img v-if="item.backPic" :src="resourcesUrl + item.backPic" class="avatar">
  43. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  44. </el-upload>
  45. </el-card>
  46. </el-col>
  47. </el-row>
  48. <el-row style="width: 210px; height: 30px; text-align: center ;color: red; font-weight: bold">
  49. <span v-if="showFlagBtn">
  50. <el-button v-if="item.flag==0 && mode=='view'" type="success" size="mini" style="margin-right: 20px" @click="handleFlag(item, index)">待标记</el-button>
  51. <el-button v-if="item.flag==1 && mode=='view'" type="warning" size="mini" style="margin-right: 5px" @click="handleFlag(item, index)">已标记</el-button>
  52. <el-button v-if="mode=='view'" type="text" size="mini" @click="openOrgPicForm(item, index)">原图</el-button>
  53. <el-button v-if="mode=='view' && (orderItem.prodName.indexOf('简约') !== -1 || orderItem.prodName.indexOf('高阶') !== -1)" type="text" size="mini" @click="openCanvasParamPicForm(item, index)">工艺</el-button>
  54. <el-button v-if="item.prodName.indexOf('语音') !== -1 && mode=='view'" type="text" size="mini" @click="openYYForm(item, index)">查看语音</el-button>
  55. <el-button v-if="mode==='edit'" type="primary" size="mini" style="margin-right: 5px" @click="addOrUpdateCardItem(item)">保存</el-button>
  56. <el-button v-if="mode==='edit' && item.cardItemId" type="danger" size="mini" style="margin-right: 5px" @click="deleteCardItem(item, index)">删除</el-button>
  57. </span>
  58. </el-row>
  59. <el-row style="width: 210px; height: 30px; text-align: center ;color: red; font-weight: bold">
  60. <span>No.{{index + 1}}</span>
  61. <span v-if="showFlagBtn" style="color: white">
  62. __________
  63. </span>
  64. <span>X</span>
  65. <span v-if="mode=='view'">{{item.prodCount}}</span>
  66. <el-input type="number" size="mini" style="width: 60px;height: 20px" v-if="mode=='edit'" v-model="item.prodCount"></el-input>
  67. </el-row>
  68. </div>
  69. <div v-if="mode=='edit'" style="display: inline-block;">
  70. <el-button
  71. circle
  72. icon="el-icon-plus"
  73. @click="addCardItem">
  74. </el-button>
  75. </div>
  76. </div>
  77. <CanvasPreview v-if= "previewPicDialogVisible" ref="canvasPreviewRef"></CanvasPreview>
  78. <YuyinPreview ref="yuYinPreviewRef"></YuyinPreview>
  79. <OrgPicPreview ref="orgPicPreviewRef"></OrgPicPreview>
  80. <CanvasParamPicPreview ref="canvasParamPicPreviewRef"></CanvasParamPicPreview>
  81. </div>
  82. </template>
  83. <script>
  84. import CanvasPreview from "../canvas-preview/index";
  85. import YuyinPreview from "../yuyin-preview/index";
  86. import OrgPicPreview from "../org-pic-preview/index";
  87. import CanvasParamPicPreview from "../canvas-param-pic-preview/index";
  88. export default {
  89. components: {CanvasPreview, YuyinPreview,OrgPicPreview, CanvasParamPicPreview},
  90. data () {
  91. return {
  92. shopId: this.$store.state.user.shopId,
  93. lang: localStorage.getItem('lang') || 'zh_CN',
  94. cardItemList:[],
  95. previewPicUrl: null,
  96. prodType: null,
  97. previewPicDialogVisible: false,
  98. previewYuyinDialogVisible: false,
  99. side:null,
  100. resourcesUrl: process.env.VUE_APP_RESOURCES_URL,
  101. mode: 'view',
  102. previewWidth: 0,
  103. previewHeight: 0,
  104. bloodWidth: 0
  105. }
  106. },
  107. props: {
  108. orderItem: {
  109. default: null,
  110. type: Object
  111. },
  112. showFlagBtn:{
  113. default: true,
  114. type: Boolean
  115. }
  116. },
  117. created() {
  118. this.$nextTick(() => {
  119. this.getDataList();
  120. })
  121. },
  122. methods: {
  123. openCanvasParamPicForm(item, index){
  124. this.$nextTick(() =>{
  125. this.$refs.canvasParamPicPreviewRef.init(item)
  126. })
  127. },
  128. openYYForm(item, index){
  129. this.$nextTick(() =>{
  130. this.$refs.yuYinPreviewRef.init(item)
  131. })
  132. },
  133. openOrgPicForm(item, index){
  134. this.$nextTick(() =>{
  135. this.$refs.orgPicPreviewRef.init(item)
  136. })
  137. },
  138. previewLoad(event){
  139. this.previewWidth = event.srcElement.clientWidth;
  140. this.previewHeight = event.srcElement.clientHeight;
  141. },
  142. handleBeforeUpload(file, fileList, item){
  143. let fileType = file.type;
  144. let isJpg = fileType === 'image/jpg' || fileType === 'image/jpeg';
  145. if(!isJpg){
  146. this.$message.error("只允许上传JPG格式的图片");
  147. return false;
  148. }
  149. let isSize = true;
  150. //如果当前是编辑的小卡,就需要判断是否符合尺寸
  151. let width = 709;
  152. let height = 1087;
  153. let prodName = item.prodName;
  154. let that = this;
  155. isSize = new Promise(function(resolve, reject) {
  156. if(prodName.indexOf("小卡") !== -1 || prodName.indexOf("影像级花式拍立得") !== -1){
  157. width = 709;
  158. height = 1087;
  159. }else if(prodName.indexOf("票根") !== -1){
  160. width = 780;
  161. height = 1489;
  162. }else if(prodName.indexOf("直拍封面") !== -1){
  163. debugger
  164. if(that.shopId === 6){
  165. width = 709;
  166. height = 1228;
  167. }else{
  168. width = 732;
  169. height = 1252;
  170. }
  171. } else if(prodName.indexOf("超清二宫格") !== -1){
  172. width = 1228;
  173. height = 709;
  174. }else if(prodName.indexOf("二宫格") !== -1){
  175. width = 1252;
  176. height = 732;
  177. }else if(prodName.indexOf("明信片") !== -1){
  178. width = 1229;
  179. height = 1796;
  180. }else if(prodName.indexOf("三宫格") !== -1){
  181. width = 673;
  182. height = 1547;
  183. }else if(prodName.indexOf("书签") !== -1){
  184. width = 638;
  185. height = 1796;
  186. }else if(prodName.indexOf("竖版四宫格") !== -1){
  187. width = 638;
  188. height = 1796;
  189. }else if(prodName.indexOf("小方卡") !== -1){
  190. width = 673;
  191. height = 673;
  192. }else if(prodName.indexOf("方卡") !== -1){
  193. width = 1252;
  194. height = 1252;
  195. }else if(prodName.indexOf("手幅") !== -1){
  196. width = 1252;
  197. height = 3614;
  198. }else if(prodName.indexOf("毛绒徽章") !== -1){
  199. width = 827;
  200. height = 827;
  201. }else if(prodName.indexOf("圆形徽章") !== -1){
  202. width = 850;
  203. height = 850;
  204. }else if(prodName.indexOf("手幅") !== -1){
  205. width = 1252;
  206. height = 3614;
  207. }else if(prodName.indexOf("4寸典藏级花式拍立得") !== -1){
  208. width = 921;
  209. height = 1087;
  210. }else if(prodName.indexOf("4寸花式拍立得") !== -1){
  211. width = 921;
  212. height = 1087;
  213. }else if(prodName.indexOf("5寸典藏级花式拍立得") !== -1){
  214. width = 1346;
  215. height = 1087;
  216. }else if(prodName.indexOf("长方形贴纸") !== -1){
  217. width = 780;
  218. height = 1134;
  219. }else if(prodName.indexOf("方形贴纸") !== -1){
  220. width = 662;
  221. height = 662;
  222. }else if(prodName.indexOf("撕拉") !== -1){
  223. width = 768;
  224. height = 768;
  225. }else if(prodName.indexOf("5寸直角卡") !== -1){
  226. width = 1087;
  227. height = 1347;
  228. }else if(prodName.indexOf("63x108") !== -1){
  229. width = 874;
  230. height = 1287;
  231. }else if(prodName.indexOf("60x180") !== -1){
  232. width = 780;
  233. height = 2197;
  234. }else if(prodName.indexOf("70x210") !== -1){
  235. width = 898;
  236. height = 2551;
  237. }else if(prodName.indexOf("游戏") !== -1){
  238. width = 803;
  239. height = 1098;
  240. }
  241. let _URL = window.URL || window.webkitURL;
  242. let img = new Image();
  243. img.onload = function() {
  244. let valid = img.width == width && img.height == height;
  245. valid ? resolve() : reject();
  246. };
  247. img.src = _URL.createObjectURL(file);
  248. }).then(
  249. () => {
  250. return file;
  251. },
  252. () => {
  253. this.$message.error("上传的图片宽高必须是" + width + "*" + height);
  254. return Promise.reject();
  255. }
  256. );
  257. return isJpg && isSize;
  258. },
  259. deleteCardItem(item, index){
  260. this.$confirm('确定要删除吗?', '提示', {
  261. confirmButtonText: '确定',
  262. cancelButtonText: '取消',
  263. type: 'warning'
  264. }).then(() => {
  265. this.$http({
  266. url: this.$http.adornUrl('/prod/orderCardItem/' + item.cardItemId),
  267. method: 'delete',
  268. }).then(({ data }) =>{
  269. if(data){
  270. this.$delete(this.cardItemList, index);
  271. this.$message.success("删除成功");
  272. }else{
  273. this.$message.error("删除失败");
  274. }
  275. })
  276. });
  277. },
  278. addOrUpdateCardItem(item){
  279. this.$confirm('确定要更新吗?', '提示', {
  280. confirmButtonText: '确定',
  281. cancelButtonText: '取消',
  282. type: 'warning'
  283. }).then(() => {
  284. this.$http({
  285. url: this.$http.adornUrl('/prod/orderCardItem/saveOrUpdate'),
  286. method: 'post',
  287. data: this.$http.adornData(item)
  288. }).then(({ data }) =>{
  289. if(data){
  290. this.$set(item, 'cardItemId', data.cardItemId);
  291. this.$message.success("保存成功");
  292. }else{
  293. this.$message.error("保存失败");
  294. }
  295. })
  296. });
  297. },
  298. onFrontUploadSuccess (item, response, file) {
  299. this.$set(item,'frontPic',response.filePath);
  300. this.$forceUpdate()
  301. },
  302. onBackUploadSuccess (item, response, file) {
  303. this.$set(item,'backPic',response.filePath);
  304. this.$forceUpdate()
  305. },
  306. addCardItem(){
  307. if(this.cardItemList.length > 0){
  308. let item = this.cardItemList[0];
  309. let newItem = {orderNumber: item.orderNumber, orderItemId: this.orderItem.orderItemId, prodName: item.prodName, skuName: item.skuName, flag: 0, prodCount: 1 }
  310. this.cardItemList.push(newItem);
  311. }else{
  312. let newItem = {orderNumber: this.orderItem.orderNumber, orderItemId: this.orderItem.orderItemId, prodName: this.orderItem.prodName, skuName: this.orderItem.skuName, flag: 0, prodCount: 1}
  313. this.cardItemList.push(newItem);
  314. }
  315. },
  316. handleFlag(item, index){
  317. let fl = item.flag == 1? 0 : 1
  318. this.$http({
  319. url: this.$http.adornUrl('/prod/orderCardItem/flag'),
  320. method: 'post',
  321. data: this.$http.adornParams(
  322. Object.assign({
  323. cardItemId: item.cardItemId,
  324. flag: fl
  325. },
  326. )
  327. )
  328. }).then(({data}) => {
  329. if(data){
  330. this.$message({
  331. message: "标记完成",
  332. type: 'success',
  333. });
  334. this.cardItemList[index].flag = fl;
  335. }else{
  336. this.$message({
  337. message: "标记失败",
  338. type: 'error',
  339. })
  340. }
  341. })
  342. },
  343. previewPic(cardItem, picUrl, prodName, side){
  344. this.previewPicUrl = this.resourcesUrl + picUrl
  345. this.previewPicDialogVisible = true;
  346. this.side = side;
  347. if(prodName.indexOf('小卡') != -1){
  348. this.prodType = '小卡';
  349. } else if(prodName.indexOf('3寸花式拍立得') != -1){
  350. this.prodType = '3寸花式拍立得';
  351. }else if(prodName.indexOf('4寸典藏级花式拍立得') != -1){
  352. this.prodType = '4寸典藏级花式拍立得';
  353. }else if(prodName.indexOf('4寸花式拍立得') != -1){
  354. this.prodType = '4寸花式拍立得';
  355. }else if(prodName.indexOf('5寸典藏级花式拍立得') != -1){
  356. this.prodType = '5寸典藏级花式拍立得';
  357. }else if(prodName.indexOf('直拍封面') != -1){
  358. this.prodType = '直拍封面';
  359. }else if(prodName.indexOf('票根') != -1){
  360. this.prodType = '票根';
  361. }else if(prodName.indexOf('明信片') != -1){
  362. this.prodType = '明信片';
  363. }else if(prodName.indexOf('小方卡') != -1){
  364. this.prodType = '小方卡';
  365. }else if(prodName.indexOf('方卡') != -1){
  366. this.prodType = '方卡';
  367. }else if(prodName.indexOf('四宫格书签') != -1){
  368. this.prodType = '四宫格书签';
  369. }else if(prodName.indexOf('徽章') != -1){
  370. this.prodType = '徽章';
  371. }else if(prodName.indexOf('手幅') != -1){
  372. this.prodType = '手幅';
  373. }else if(prodName.indexOf('毛绒徽章') != -1){
  374. this.prodType = '毛绒徽章';
  375. }else if(prodName.indexOf('三宫格') != -1){
  376. this.prodType = '三宫格';
  377. }else if(prodName.indexOf('长方形贴纸') != -1){
  378. this.prodType = '长方形贴纸';
  379. }else if(prodName.indexOf('方形贴纸') != -1){
  380. this.prodType = '方形贴纸';
  381. }else if(prodName.indexOf('二宫格') != -1){
  382. this.prodType = '二宫格';
  383. }else if(prodName.indexOf('撕拉') != -1){
  384. this.prodType = '撕拉';
  385. }else if(prodName.indexOf('5寸直角卡') != -1){
  386. this.prodType = '5寸直角卡';
  387. }else if(prodName.indexOf('游戏') != -1){
  388. this.prodType = '游戏';
  389. }
  390. this.$nextTick(() =>{
  391. this.$refs.canvasPreviewRef.init(cardItem, this.resourcesUrl + picUrl, this.prodType, side)
  392. })
  393. },
  394. getDataList () {
  395. this.$http({
  396. url: this.$http.adornUrl('/prod/orderCardItem/page'),
  397. method: 'get',
  398. params: this.$http.adornParams(
  399. Object.assign({
  400. size: 300,
  401. orderNumber: this.orderItem.orderNumber,
  402. orderItemId: this.orderItem.orderItemId,
  403. },
  404. )
  405. )
  406. }).then(({data}) => {
  407. this.cardItemList = data.records;
  408. })
  409. },
  410. }
  411. }
  412. </script>
  413. <style lang="scss" scoped>
  414. .previewClass{
  415. position:absolute;
  416. border-style:solid;
  417. border-color:red;
  418. opacity:0.3;
  419. z-index:3;
  420. }
  421. #cardBottom{
  422. position:absolute;
  423. z-index:1;
  424. }
  425. .avatar-uploader .el-upload {
  426. border: 1px dashed #d9d9d9;
  427. border-radius: 6px;
  428. cursor: pointer;
  429. position: relative;
  430. overflow: hidden;
  431. }
  432. .avatar-uploader .el-upload:hover {
  433. border-color: #409EFF;
  434. }
  435. .avatar-uploader-icon {
  436. font-size: 28px;
  437. color: #8c939d;
  438. width: 100px;
  439. height: 100px;
  440. line-height: 100px;
  441. text-align: center;
  442. }
  443. .avatar {
  444. width: 100px;
  445. height: 100px;
  446. display: block;
  447. }
  448. /* .prods-select-body {
  449. height: 600px;
  450. overflow: auto;
  451. border-top: 1px solid #eeeeee;
  452. border-right: 1px solid #eeeeee;
  453. border-bottom: 1px solid #eeeeee;
  454. } */
  455. .brand-select-pop {
  456. & ::v-deep .el-dialog__body {
  457. padding-top: 20px;
  458. padding-bottom: 20px;
  459. }
  460. .main-container {
  461. margin: 0;
  462. .pagination {
  463. text-align: right;
  464. }
  465. }
  466. }
  467. </style>