DesignPic.tsx 26 KB

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