DesignPic.tsx 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. import React, { useState, useEffect } from 'react'
  2. import { Button, Table, Input, Message, Loading, Radio, Balloon } from '@alifd/next';
  3. import { CustomMessage } from '@/components/CustomMessage'
  4. import { urlToFile } from './utils';
  5. import IconCom from '@/components/IconCom';
  6. const RadioGroup = Radio.Group
  7. export default function DesignPic() {
  8. const [uploadUrl, setUploadUrl] = useState<string>("");
  9. // 添加状态管理表格数据
  10. const [tableData, setTableData] = useState<any[]>([]);
  11. const [loading, setLoading] = useState(false);
  12. const [isPage, setIsPage] = useState(true);
  13. const [btnLoading, setBtnLoading] = useState(false);
  14. const [isPreImg, setIsPreImg] = useState(-1)
  15. const [errImgDatas, setErrImgDatas] = useState<any[]>([])
  16. useEffect(() => {
  17. is_temu_design()
  18. }, [])
  19. const is_temu_design = async () => {
  20. try {
  21. // 获取当前活动标签页
  22. const [tab] = await browser.tabs.query({ active: true, currentWindow: true });
  23. // 获取页面域名
  24. if (tab.url) {
  25. const url = tab.url
  26. console.log('当前页面域名:', url);
  27. if (url.includes('main/customize-goods')) {
  28. // temu定制页面
  29. setIsPage(false)
  30. }
  31. }
  32. } catch (error) {
  33. console.error('获取当前页面域名时出错:', error);
  34. }
  35. }
  36. const order_render = (value: any, index: any, record: any) => {
  37. return (
  38. <div>{index + 1}</div>
  39. )
  40. }
  41. const design_render = (value: any, index: any, record: any) => {
  42. return <>
  43. {
  44. record.pre_info && record.pre_info.pre_pic ? <>
  45. <div className='flex items-center justify-center'><img className='size-20' src={record.pre_info?.pre_pic} /></div></> : <>
  46. <span>暂无图片</span>
  47. </>
  48. }
  49. </>
  50. }
  51. const pic_render = (value: any, index: any, record: any) => {
  52. return (
  53. <>
  54. {
  55. record.design_pic ? <>
  56. <div className='flex items-center justify-center'><img className='size-20' src={record.design_pic} /></div></> : <>
  57. <span>暂无图片</span>
  58. </>
  59. }
  60. </>
  61. );
  62. }
  63. const text_render = (value: any, index: any, record: any) => {
  64. return (
  65. <p>{record.text}</p>
  66. );
  67. }
  68. // 修改图片名称渲染函数
  69. const name_render = (value: any, index: number, record: any) => {
  70. return <>
  71. <div>{record.order_no}</div>
  72. </>
  73. };
  74. // 修改图片标签渲染函数
  75. const label_render = (value: any, index: number, record: any) => {
  76. return <>
  77. <div>{record.region}</div>
  78. </>
  79. };
  80. // 完善删除功能
  81. const handleDelete = (index: number, record: any) => {
  82. // 方案1: 直接删除
  83. const newData = [...tableData];
  84. newData.splice(index, 1);
  85. setTableData(newData);
  86. // 方案2: 带确认的删除 (可选)
  87. // if (window.confirm(`确定要删除 "${record.title.name}" 吗?`)) {
  88. // const newData = [...tableData];
  89. // newData.splice(index, 1);
  90. // setTableData(newData);
  91. // Message.success('删除成功');
  92. // }
  93. };
  94. // 删除操作渲染函数
  95. const option_render = (value: any, index: number, record: any) => {
  96. return (
  97. record.is_upload ? <p className='text-green-600'>上传成功</p> : <div className='flex justify-between' style={{ alignItems: 'center' }}>
  98. <a
  99. className='text-red-600 cursor-pointer'
  100. onClick={() => handleDelete(index, record)}
  101. >
  102. 删除
  103. </a>
  104. {record.is_error && <p className='text-gray-600' style={{ marginBottom: 0 }}>上传失败</p>}
  105. </div>
  106. );
  107. };
  108. // 添加行索引以确保正确删除
  109. const dataSourceWithIndex = tableData.map((item, index) => ({
  110. ...item,
  111. index
  112. }));
  113. const getPicData = async () => {
  114. const [tab] = await browser.tabs.query({ active: true, currentWindow: true });
  115. // 获取页面域名
  116. if (tab.url) {
  117. const url = tab.url
  118. if (!url.includes('main/customize-goods')) {
  119. // temu定制页面
  120. CustomMessage.error('当前页面不是定制页面')
  121. return
  122. }
  123. }
  124. try {
  125. setLoading(true)
  126. // 获取上传路径
  127. fetch('http://merchant.landwu.com/api/photo/getUploadUrl', {
  128. method: 'POST',
  129. headers: {
  130. 'Content-Type': 'application/json',
  131. },
  132. body: JSON.stringify({
  133. api_token: localStorage.getItem('access_token'),
  134. }),
  135. }).then(resjson => {
  136. return resjson.json();
  137. }).then(res => {
  138. if (res.data) {
  139. const { data = {} } = res;
  140. const { url = null } = data;
  141. setUploadUrl(url)
  142. }
  143. }).catch(e => {
  144. setLoading(false)
  145. })
  146. setTableData([])
  147. setBtnLoading(true)
  148. // 获取当前活动标签页
  149. const [tab] = await browser.tabs.query({ active: true, currentWindow: true });
  150. if (tab.id) {
  151. // 发送消息到content script请求获取tbody数据
  152. const response = await browser.tabs.sendMessage(tab.id, { action: "getTbodyData" });
  153. // 在控制台输出结果
  154. if (response.tables && response.tables.length > 0) {
  155. // console.log("找到的表格数据(包含背景图片):");
  156. // 显式声明类型
  157. let tables_arr: {
  158. good_info: any;
  159. sku_info: any;
  160. order_no: any;
  161. design_sku: any;
  162. pre_design_info: any;
  163. design_info: { region: any; text: any; picture: any }[];
  164. }[] = [];
  165. let table_boj: {
  166. good_info: any;
  167. sku_info: any;
  168. order_no: any;
  169. design_sku: any;
  170. pre_design_info: any;
  171. design_info: { region: any; text: any; picture: any }[];
  172. } = {
  173. good_info: null,
  174. sku_info: null,
  175. order_no: null,
  176. design_sku: null,
  177. pre_design_info: null,
  178. design_info: []
  179. };
  180. response.tables.forEach((table_node: any, index: number) => {
  181. console.log(`表格 ${index + 1}:`, table_node);
  182. // 处理成接口参数
  183. // 处理成数组对象
  184. if (table_node.length > 4) {
  185. if (table_boj.design_info.length) {
  186. // 一个商品的定制信息
  187. tables_arr.push(table_boj)
  188. // 重置
  189. table_boj = {
  190. good_info: null,
  191. sku_info: null,
  192. order_no: null,
  193. design_sku: null,
  194. pre_design_info: null,
  195. design_info: []
  196. }
  197. }
  198. table_boj = {
  199. good_info: table_node[1],
  200. sku_info: table_node[2],
  201. order_no: table_node[3],
  202. design_sku: table_node[4],
  203. pre_design_info: table_node[13],
  204. design_info: [{
  205. region: table_node[9],
  206. text: table_node[10],
  207. picture: table_node[11],//11
  208. }]
  209. }
  210. } else {
  211. table_boj.design_info.push({
  212. region: table_node[0],
  213. text: table_node[1],
  214. picture: table_node[2],//2
  215. })
  216. }
  217. // 循环结束
  218. if (index == response.tables.length - 1) {
  219. if (table_boj.design_info.length) {
  220. // 一个商品的定制信息
  221. tables_arr.push(table_boj)
  222. }
  223. }
  224. // good_info sku_info design_info: region text picture
  225. });
  226. console.log(tables_arr, "tables_arrddd")
  227. // 上传图片和文字的参数处理
  228. let pic_text_arr: any[] = [], img_values: any = {}
  229. tables_arr.forEach(item => {
  230. let order_no = "", data_params: any[] = [], pre_info = {};
  231. if (item.order_no && item.order_no != "-") {
  232. // order_no = item.order_no.substring(0, 15); // 取前15位
  233. order_no = item.order_no
  234. }
  235. if (order_no) {
  236. let pre_pic = ""
  237. if (item.pre_design_info && item.pre_design_info != '-') {
  238. let pre_pic1 = (item.pre_design_info.backgroundImages as { url: string }[] | undefined)?.[0]?.url ?? '';
  239. pre_pic = pre_pic1.split('&imageMogr2/thumbnail')[0]
  240. if (!img_values[pre_pic]) {
  241. img_values[pre_pic] = {
  242. src: pre_pic,
  243. width: '',
  244. height: '',
  245. order_no,
  246. file: ''
  247. }
  248. }
  249. if (pre_pic) {
  250. pre_info = {
  251. pre_pic,
  252. width: 400,
  253. height: 400
  254. }
  255. }
  256. } else {
  257. pre_pic = ""
  258. }
  259. }
  260. // 定制信息处理
  261. if (item.design_info.length) {
  262. item.design_info.forEach(items => {
  263. const param: any = {}
  264. if (order_no || item.design_sku) {
  265. let bg_pic = ""
  266. if (items.picture && items.picture != '-') {
  267. let bg_pic1 = (items.picture.backgroundImages as { url: string }[] | undefined)?.[0]?.url ?? '';
  268. bg_pic = bg_pic1.split('&imageMogr2/thumbnail')[0]
  269. if (!img_values[bg_pic]) {
  270. img_values[bg_pic] = {
  271. src: bg_pic,
  272. width: '',
  273. height: ''
  274. }
  275. }
  276. if (bg_pic) {
  277. param['width'] = 400;
  278. param['height'] = 400;
  279. }
  280. } else {
  281. bg_pic = ""
  282. }
  283. let des_text = ""
  284. if (items.text && items.text != '-') {
  285. const des_text1 = items.text.split(";}")[1]
  286. des_text = des_text1.split("查看")[0]
  287. } else {
  288. des_text = ""
  289. }
  290. param['region'] = items.region
  291. param['text'] = des_text
  292. param['design_pic'] = bg_pic
  293. data_params.push(param)
  294. }
  295. })
  296. }
  297. if (order_no || item.design_sku) {
  298. pic_text_arr.push({
  299. order_no,
  300. design_sku: item.design_sku,
  301. pre_info,
  302. data_params
  303. })
  304. }
  305. })
  306. // console.log(img_values,'-img_valuesimg_values')
  307. let img_values1: any = {}, cIndex = 0
  308. Object.values(img_values).forEach((item, n) => {
  309. if (!img_values1[n]) {
  310. img_values1[n] = item
  311. }
  312. })
  313. const queueImg = () => {
  314. if (img_values1[cIndex]) {
  315. cIndex++
  316. queueImg()
  317. return
  318. {
  319. let img = new Image()
  320. img.onload = function () {
  321. img_values1[cIndex].width = img.width
  322. img_values1[cIndex].height = img.height
  323. img_values[img_values1[cIndex]?.src]['width'] = img.width
  324. img_values[img_values1[cIndex]?.src]['height'] = img.height
  325. cIndex++
  326. queueImg()
  327. }
  328. img.onerror = function () {
  329. cIndex++
  330. queueImg()
  331. }
  332. img.src = img_values1[cIndex]?.src
  333. }
  334. } else {
  335. getImgWh()
  336. }
  337. }
  338. queueImg()
  339. function getImgWh() {
  340. setBtnLoading(false)
  341. setLoading(false)
  342. // 筛选备货单号存在的值
  343. let pic_text_arr1 = pic_text_arr.filter(item => item.order_no && item.order_no != "-")
  344. // 为存在图片的对象添加宽高
  345. // pic_text_arr1.map(item => {
  346. // item.data_params.map((items: any) => {
  347. // if (items.design_pic) {
  348. // if (img_values[items.design_pic]) {
  349. // items['width'] = img_values[items.design_pic].width
  350. // items['height'] = img_values[items.design_pic].height
  351. // items['file'] = img_values[items.design_pic].file
  352. // }
  353. // }
  354. // })
  355. // if (item.pre_info && item.pre_info.pre_pic) {
  356. // item.pre_info.width = img_values[item.pre_info.pre_pic].width
  357. // item.pre_info.height = img_values[item.pre_info.pre_pic].height
  358. // }
  359. // })
  360. // 数据显示
  361. let table_data: any[] = []
  362. pic_text_arr1.forEach(item => {
  363. if (item.data_params.length) {
  364. item.data_params.forEach((items: any) => {
  365. table_data.push({
  366. order_no: item.order_no,
  367. pre_info: item.pre_info,
  368. design_sku: item.design_sku,
  369. design_pic: items.design_pic,
  370. file: items.file,
  371. region: items.region,
  372. text: items.text,
  373. width: items.width || "",
  374. height: items.height || "",
  375. })
  376. })
  377. }
  378. })
  379. console.log(pic_text_arr1, "pic_text_arr1aaa", img_values1)
  380. // console.log(table_data, "table_data")
  381. setTableData(table_data)
  382. }
  383. } else {
  384. console.log("页面上未找到表格数据");
  385. CustomMessage.error("页面上未找到表格数据");
  386. }
  387. }
  388. } catch (error) {
  389. setBtnLoading(false)
  390. setLoading(false)
  391. console.error("获取表格数据失败:", error);
  392. CustomMessage.error("获取表格数据失败");
  393. }
  394. };
  395. interface imgValuesProps {
  396. [key: string]: {
  397. design_pic: string,
  398. design_sku: string
  399. url: string
  400. width: string | number
  401. height: string | number
  402. },
  403. }
  404. const uploadPic = () => {
  405. try {
  406. const token = localStorage.getItem("access_token");
  407. console.log(tableData, "tableData")
  408. let table_obj: { [key: string]: any } = {},
  409. img_values: imgValuesProps = {}, fetch_url = "";
  410. tableData.forEach(item => {
  411. // 定制图
  412. if (item.design_pic && !img_values[item.design_pic]) {
  413. img_values[item.design_pic] = {
  414. design_pic: item.design_pic,
  415. design_sku: item.design_sku,
  416. url: '',
  417. width: '',
  418. height: ''
  419. }
  420. }
  421. if (isPreImg == 1) {
  422. // 预览图
  423. if (item.pre_info && item.pre_info.pre_pic && !img_values[item.pre_info.pre_pic]) {
  424. img_values[item.pre_info.pre_pic] = {
  425. design_pic: item.pre_info.pre_pic,
  426. design_sku: item.design_sku,
  427. url: '',
  428. width: '',
  429. height: ''
  430. }
  431. }
  432. }
  433. if (!table_obj[item.design_sku]) {
  434. table_obj[item.design_sku] = ""
  435. }
  436. if (table_obj[item.design_sku]) {
  437. const data_params = table_obj[item.design_sku].data_params
  438. data_params.push({
  439. design_pic: item.design_pic,
  440. file: item.file || "",
  441. region: item.region,
  442. text: item.text,
  443. width: item.width,
  444. height: item.height,
  445. })
  446. table_obj[item.design_sku] = {
  447. ...table_obj[item.design_sku],
  448. data_params,
  449. }
  450. } else {
  451. if (isPreImg == 1) {
  452. table_obj[item.design_sku] = {
  453. order_no: item.order_no,
  454. design_sku: item.design_sku,
  455. pre_info: item.pre_info,
  456. data_params: [{
  457. design_pic: item.design_pic,
  458. file: item.file || '',
  459. region: item.region,
  460. text: item.text,
  461. width: item.width,
  462. height: item.height,
  463. }]
  464. }
  465. } else {
  466. table_obj[item.design_sku] = {
  467. order_no: item.order_no,
  468. design_sku: item.design_sku,
  469. data_params: [{
  470. design_pic: item.design_pic,
  471. file: item.file || '',
  472. region: item.region,
  473. text: item.text,
  474. width: item.width,
  475. height: item.height,
  476. }]
  477. }
  478. }
  479. }
  480. })
  481. // if (uploadUrl.includes('http')) {
  482. // fetch_url = `${uploadUrl}photo/temuUploadStepTwo`
  483. // } else {
  484. // fetch_url = `https://usersource.landwu.com/photo/temuUploadStepTwo`
  485. // }
  486. // if (!uploadUrl) {
  487. // CustomMessage.warning("上传地址丢失,请再次点击获取定制数据!")
  488. // return
  489. // }
  490. fetch_url = `https://usersource.landwu.com/api/photo/temuUploadStepTwo`
  491. if (Object.values(img_values) && Object.values(img_values).length) {
  492. let queImgs: any = {}, queImgsCindex = 0, imgall_values: any = {};
  493. Object.values(img_values).forEach((v, cindex) => {
  494. if (!queImgs[cindex]) {
  495. queImgs[cindex] = {
  496. design_pic: v.design_pic,
  497. design_sku: v.design_sku,
  498. }
  499. }
  500. })
  501. const imgUpdate = () => {
  502. if (queImgs[queImgsCindex]) {
  503. setLoading(true)
  504. urlToFile(queImgs[queImgsCindex]?.design_pic, `${new Date().getTime()}.png`).then(file => {
  505. if (!file) {
  506. // 图片转化二进制失败
  507. errImgDatas.push(queImgs[queImgsCindex])
  508. setErrImgDatas(errImgDatas);
  509. queImgsCindex++
  510. imgUpdate()
  511. return
  512. }
  513. // photo/temuUploadStepTwo
  514. let form_data = new FormData()
  515. form_data.append('api_token', token as string)
  516. form_data.append('file', file)
  517. fetch(`https://usersource.landwu.com/api/photo/temuUploadStepOne`, {
  518. method: 'POST',
  519. headers: {
  520. // 'Content-Type': 'multipart/form-data',
  521. 'access-control-allow-credentials': 'true',
  522. 'X-CSRF-TOKEN': 'Bearer ' + token,
  523. 'Authorization': 'Bearer ' + token,
  524. },
  525. body: form_data,
  526. }).then(resjson => {
  527. return resjson.json();
  528. }).then(res => {
  529. const { data } = res;
  530. if (!imgall_values[queImgs[queImgsCindex].design_sku]) {
  531. imgall_values[queImgs[queImgsCindex].design_sku] = {
  532. }
  533. }
  534. if (!imgall_values[queImgs[queImgsCindex].design_sku][queImgs[queImgsCindex].design_pic]) {
  535. imgall_values[queImgs[queImgsCindex].design_sku][queImgs[queImgsCindex].design_pic] = {
  536. ...data
  537. }
  538. }
  539. if (imgall_values[queImgs[queImgsCindex].design_sku][queImgs[queImgsCindex].design_pic]) {
  540. imgall_values[queImgs[queImgsCindex].design_sku][queImgs[queImgsCindex].design_pic] = {
  541. ...data
  542. }
  543. }
  544. queImgsCindex++
  545. imgUpdate()
  546. }).catch(error => {
  547. queImgsCindex++
  548. imgUpdate()
  549. })
  550. })
  551. } else {
  552. for (let key in table_obj) {
  553. if (imgall_values[key]) {
  554. // 定制图
  555. if (table_obj[key].data_params && Array.isArray(table_obj[key].data_params) && table_obj[key].data_params.length) {
  556. const design_pic = table_obj[key].data_params.find((item: any) => item.design_pic)
  557. if (design_pic) {
  558. table_obj[key].data_params.map((item: any) => {
  559. if (item.design_pic && imgall_values[key][item.design_pic]) {
  560. const { width, height, url, type } = imgall_values[key][item.design_pic]
  561. item['width'] = width
  562. item['height'] = height
  563. item['file'] = url
  564. item['type'] = type
  565. // console.log(item)
  566. }
  567. return item
  568. })
  569. }
  570. }
  571. // 预览图
  572. if (isPreImg == 1) {
  573. if (table_obj[key].pre_info && table_obj[key].pre_info.pre_pic && imgall_values[key][table_obj[key].pre_info.pre_pic]) {
  574. const { width, height, url, type } = imgall_values[key][table_obj[key].pre_info.pre_pic]
  575. table_obj[key].pre_info = {
  576. ...table_obj[key].pre_info,
  577. width,
  578. height,
  579. file: url,
  580. type,
  581. }
  582. }
  583. }
  584. }
  585. }
  586. // console.log(imgall_values, '-imgall_values', table_obj)
  587. imgFetchFun(table_obj)
  588. }
  589. }
  590. imgUpdate()
  591. return
  592. }
  593. function imgFetchFun(table_obj: any) {
  594. const table_params = Object.values(table_obj)
  595. let arr_index = 0
  596. const FetchFun = (params: any) => {
  597. params['api_token'] = token
  598. fetch(fetch_url, {
  599. method: 'POST',
  600. headers: {
  601. 'Content-Type': 'application/json',
  602. },
  603. body: JSON.stringify(params),
  604. }).then(resjson => {
  605. return resjson.json();
  606. }).then(res => {
  607. if (res.data.error && res.data.error.length) {
  608. // 未上传成功的 图片
  609. console.log(res.data.error, "arr_index", arr_index)
  610. res.data.error.forEach((item: any) => {
  611. CustomMessage.error(item.design_pic)
  612. })
  613. }
  614. // tableData循环出备货单相同的数据,修改表格操作数据 is_upload
  615. let tableData1 = tableData.map(item => {
  616. if (item.order_no == params.order_no) {
  617. // console.log(item.order_no, "item.order_no", params)
  618. item.is_upload = true
  619. }
  620. // console.log(errImgDatas, "errImgDatas")
  621. errImgDatas.forEach((items) => {
  622. // 定制图上传失败
  623. if (items.design_pic == item.design_pic) {
  624. // 429错误
  625. item.is_upload = false
  626. item.is_error = true
  627. }
  628. // 预览图上传失败 概率小速度慢暂时不做处理
  629. // if (isPreImg == 1) {
  630. // if (items.design_pic == item.pre_info.pre_pic) {
  631. // item.is_upload = false
  632. // item.is_error = true
  633. // }
  634. // }
  635. })
  636. return item
  637. })
  638. setTableData(tableData1)
  639. arr_index++
  640. if (arr_index < table_params.length) {
  641. // console.log(tableData1,"tableData111")
  642. FetchFun(table_params[arr_index])
  643. } else {
  644. setLoading(false)
  645. setTableData(tableData.filter(item => !item.is_upload))
  646. setErrImgDatas([])
  647. CustomMessage.success("图片上传结束")
  648. }
  649. }).catch(err => {
  650. // console.log(err, "err")
  651. arr_index++
  652. if (arr_index < table_params.length) {
  653. FetchFun(table_params[arr_index])
  654. } else {
  655. setLoading(false)
  656. setTableData(tableData.filter(item => !item.is_upload))
  657. setErrImgDatas([])
  658. CustomMessage.success("图片上传结束")
  659. }
  660. })
  661. }
  662. setLoading(true)
  663. FetchFun(table_params[arr_index])
  664. }
  665. imgFetchFun(table_obj)
  666. } catch (error) {
  667. console.error(error, "报错")
  668. }
  669. }
  670. const evChangeRadio = (e: any) => {
  671. let ev = e && e.target ? e.target.value : e
  672. setIsPreImg(ev)
  673. }
  674. return (
  675. <Loading visible={loading} fullScreen>
  676. <div className='w-3xl h-fit'>
  677. <Button
  678. type="primary"
  679. disabled={isPage || btnLoading}
  680. style={{ marginBottom: '10px', marginRight: '10px' }}
  681. onClick={() => {
  682. getPicData()
  683. }}>获取定制数据</Button>
  684. <Button
  685. disabled={(!tableData.length) || isPage || btnLoading}
  686. type="primary"
  687. style={{ marginBottom: '10px', marginRight: '10px' }}
  688. onClick={() => {
  689. uploadPic()
  690. }}>上传定制信息</Button>
  691. <span className='text-red-500'>ps:需在Temu定制商品内容页面获取数据,且上传图片过程中请勿关闭插件</span>
  692. <div className='flex items-center' style={{ marginBottom: '10px' }}>
  693. <p style={{ fontSize: 14, marginBottom: 0, marginRight: 5 }}>是否获取合成预览图: </p>
  694. <RadioGroup value={isPreImg} onChange={(e) => {
  695. evChangeRadio(e)
  696. }} aria-labelledby="groupId">
  697. <Radio value={1}>
  698. </Radio>
  699. <Radio value={-1}>
  700. </Radio>
  701. </RadioGroup>
  702. </div>
  703. <Table dataSource={dataSourceWithIndex}>
  704. <Table.Column title="序号" cell={order_render} align="center" />
  705. <Table.Column title="备货单" cell={name_render} align="center" />
  706. {
  707. isPreImg == 1 && <Table.Column title="合成预览图" cell={design_render} align="center" />
  708. }
  709. <Table.Column title="定制区域" cell={label_render} align="center" />
  710. <Table.Column title="文字" cell={text_render} align="center" />
  711. <Table.Column title="图片" cell={pic_render} align="center" />
  712. <Table.Column title={<div className='flex justify-center items-center'>
  713. <div>操作</div><Balloon v2 closable={false} trigger={<a><IconCom type="info" _style={{cursor:'pointer', marginLeft: 5}} /></a>} align="t" triggerType="hover" style={{ width: 300 }}>
  714. 图片上传失败时,请重新点击上传定制信息按钮
  715. </Balloon>
  716. </div>} cell={option_render} align="center" />
  717. </Table>
  718. <p className='text-red-500'>ps:若获取不到数据,可能是插件未连接成功,请刷新页面</p>
  719. </div>
  720. </Loading>
  721. )
  722. }