DesignPic.tsx 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  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. }
  234. if (order_no) {
  235. let pre_pic = ""
  236. if (item.pre_design_info && item.pre_design_info != '-') {
  237. let pre_pic1 = (item.pre_design_info.backgroundImages as { url: string }[] | undefined)?.[0]?.url ?? '';
  238. pre_pic = pre_pic1.split('&imageMogr2/thumbnail')[0]
  239. if (!img_values[pre_pic]) {
  240. img_values[pre_pic] = {
  241. src: pre_pic,
  242. width: '',
  243. height: '',
  244. order_no,
  245. file: ''
  246. }
  247. }
  248. if (pre_pic) {
  249. pre_info = {
  250. pre_pic,
  251. width: 400,
  252. height: 400
  253. }
  254. }
  255. } else {
  256. pre_pic = ""
  257. }
  258. }
  259. // 定制信息处理
  260. if (item.design_info.length) {
  261. item.design_info.forEach(items => {
  262. const param: any = {}
  263. if (order_no || item.design_sku) {
  264. let bg_pic = ""
  265. if (items.picture && items.picture != '-') {
  266. let bg_pic1 = (items.picture.backgroundImages as { url: string }[] | undefined)?.[0]?.url ?? '';
  267. bg_pic = bg_pic1.split('&imageMogr2/thumbnail')[0]
  268. if (!img_values[bg_pic]) {
  269. img_values[bg_pic] = {
  270. src: bg_pic,
  271. width: '',
  272. height: ''
  273. }
  274. }
  275. if (bg_pic) {
  276. param['width'] = 400;
  277. param['height'] = 400;
  278. }
  279. } else {
  280. bg_pic = ""
  281. }
  282. let des_text = ""
  283. if (items.text && items.text != '-') {
  284. const des_text1 = items.text.split(";}")[1]
  285. des_text = des_text1.split("查看")[0]
  286. } else {
  287. des_text = ""
  288. }
  289. param['region'] = items.region
  290. param['text'] = des_text
  291. param['design_pic'] = bg_pic
  292. data_params.push(param)
  293. }
  294. })
  295. }
  296. if (order_no || item.design_sku) {
  297. pic_text_arr.push({
  298. order_no,
  299. design_sku: item.design_sku,
  300. pre_info,
  301. data_params
  302. })
  303. }
  304. })
  305. // console.log(img_values,'-img_valuesimg_values')
  306. let img_values1: any = {}, cIndex = 0
  307. Object.values(img_values).forEach((item, n) => {
  308. if (!img_values1[n]) {
  309. img_values1[n] = item
  310. }
  311. })
  312. const queueImg = () => {
  313. if (img_values1[cIndex]) {
  314. cIndex++
  315. queueImg()
  316. return
  317. {
  318. let img = new Image()
  319. img.onload = function () {
  320. img_values1[cIndex].width = img.width
  321. img_values1[cIndex].height = img.height
  322. img_values[img_values1[cIndex]?.src]['width'] = img.width
  323. img_values[img_values1[cIndex]?.src]['height'] = img.height
  324. cIndex++
  325. queueImg()
  326. }
  327. img.onerror = function () {
  328. cIndex++
  329. queueImg()
  330. }
  331. img.src = img_values1[cIndex]?.src
  332. }
  333. } else {
  334. getImgWh()
  335. }
  336. }
  337. queueImg()
  338. function getImgWh() {
  339. setBtnLoading(false)
  340. setLoading(false)
  341. // 筛选备货单号存在的值
  342. let pic_text_arr1 = pic_text_arr.filter(item => item.order_no && item.order_no != "-")
  343. // 为存在图片的对象添加宽高
  344. // pic_text_arr1.map(item => {
  345. // item.data_params.map((items: any) => {
  346. // if (items.design_pic) {
  347. // if (img_values[items.design_pic]) {
  348. // items['width'] = img_values[items.design_pic].width
  349. // items['height'] = img_values[items.design_pic].height
  350. // items['file'] = img_values[items.design_pic].file
  351. // }
  352. // }
  353. // })
  354. // if (item.pre_info && item.pre_info.pre_pic) {
  355. // item.pre_info.width = img_values[item.pre_info.pre_pic].width
  356. // item.pre_info.height = img_values[item.pre_info.pre_pic].height
  357. // }
  358. // })
  359. // 数据显示
  360. let table_data: any[] = []
  361. pic_text_arr1.forEach(item => {
  362. if (item.data_params.length) {
  363. item.data_params.forEach((items: any) => {
  364. table_data.push({
  365. order_no: item.order_no,
  366. pre_info: item.pre_info,
  367. design_sku: item.design_sku,
  368. design_pic: items.design_pic,
  369. file: items.file,
  370. region: items.region,
  371. text: items.text,
  372. width: items.width || "",
  373. height: items.height || "",
  374. })
  375. })
  376. }
  377. })
  378. console.log(pic_text_arr1, "pic_text_arr1aaa", img_values1)
  379. // console.log(table_data, "table_data")
  380. setTableData(table_data)
  381. }
  382. } else {
  383. console.log("页面上未找到表格数据");
  384. CustomMessage.error("页面上未找到表格数据");
  385. }
  386. }
  387. } catch (error) {
  388. setBtnLoading(false)
  389. setLoading(false)
  390. console.error("获取表格数据失败:", error);
  391. CustomMessage.error("获取表格数据失败");
  392. }
  393. };
  394. interface imgValuesProps {
  395. [key: string]: {
  396. design_pic: string,
  397. design_sku: string
  398. url: string
  399. width: string | number
  400. height: string | number
  401. },
  402. }
  403. const uploadPic = () => {
  404. try {
  405. const token = localStorage.getItem("access_token");
  406. console.log(tableData, "tableData")
  407. let table_obj: { [key: string]: any } = {},
  408. img_values: imgValuesProps = {}, fetch_url = "";
  409. tableData.forEach(item => {
  410. // 定制图
  411. if (item.design_pic && !img_values[item.design_pic]) {
  412. img_values[item.design_pic] = {
  413. design_pic: item.design_pic,
  414. design_sku: item.design_sku,
  415. url: '',
  416. width: '',
  417. height: ''
  418. }
  419. }
  420. if (isPreImg == 1) {
  421. // 预览图
  422. if (item.pre_info && item.pre_info.pre_pic && !img_values[item.pre_info.pre_pic]) {
  423. img_values[item.pre_info.pre_pic] = {
  424. design_pic: item.pre_info.pre_pic,
  425. design_sku: item.design_sku,
  426. url: '',
  427. width: '',
  428. height: ''
  429. }
  430. }
  431. }
  432. if (!table_obj[item.design_sku]) {
  433. table_obj[item.design_sku] = ""
  434. }
  435. if (table_obj[item.design_sku]) {
  436. const data_params = table_obj[item.design_sku].data_params
  437. data_params.push({
  438. design_pic: item.design_pic,
  439. file: item.file || "",
  440. region: item.region,
  441. text: item.text,
  442. width: item.width,
  443. height: item.height,
  444. })
  445. table_obj[item.design_sku] = {
  446. ...table_obj[item.design_sku],
  447. data_params,
  448. }
  449. } else {
  450. if (isPreImg == 1) {
  451. table_obj[item.design_sku] = {
  452. order_no: item.order_no,
  453. design_sku: item.design_sku,
  454. pre_info: item.pre_info,
  455. data_params: [{
  456. design_pic: item.design_pic,
  457. file: item.file || '',
  458. region: item.region,
  459. text: item.text,
  460. width: item.width,
  461. height: item.height,
  462. }]
  463. }
  464. } else {
  465. table_obj[item.design_sku] = {
  466. order_no: item.order_no,
  467. design_sku: item.design_sku,
  468. data_params: [{
  469. design_pic: item.design_pic,
  470. file: item.file || '',
  471. region: item.region,
  472. text: item.text,
  473. width: item.width,
  474. height: item.height,
  475. }]
  476. }
  477. }
  478. }
  479. })
  480. if (uploadUrl.includes('http')) {
  481. fetch_url = `${uploadUrl}photo/temuUploadStepTwo`
  482. } else {
  483. fetch_url = `https:${uploadUrl}photo/temuUploadStepTwo`
  484. }
  485. if (!uploadUrl) {
  486. CustomMessage.warning("上传地址丢失,请再次点击获取定制数据!")
  487. return
  488. }
  489. if (Object.values(img_values) && Object.values(img_values).length) {
  490. let queImgs: any = {}, queImgsCindex = 0, imgall_values: any = {};
  491. Object.values(img_values).forEach((v, cindex) => {
  492. if (!queImgs[cindex]) {
  493. queImgs[cindex] = {
  494. design_pic: v.design_pic,
  495. design_sku: v.design_sku,
  496. }
  497. }
  498. })
  499. const imgUpdate = () => {
  500. if (queImgs[queImgsCindex]) {
  501. setLoading(true)
  502. urlToFile(queImgs[queImgsCindex]?.design_pic, `${new Date().getTime()}.png`).then(file => {
  503. if (!file) {
  504. // 图片转化二进制失败
  505. errImgDatas.push(queImgs[queImgsCindex])
  506. setErrImgDatas(errImgDatas);
  507. queImgsCindex++
  508. imgUpdate()
  509. return
  510. }
  511. // photo/temuUploadStepTwo
  512. let form_data = new FormData()
  513. form_data.append('api_token', token as string)
  514. form_data.append('file', file)
  515. fetch(`https:${uploadUrl}photo/temuUploadStepOne`, {
  516. method: 'POST',
  517. headers: {
  518. // 'Content-Type': 'multipart/form-data',
  519. 'access-control-allow-credentials': 'true',
  520. 'X-CSRF-TOKEN': 'Bearer ' + token,
  521. 'Authorization': 'Bearer ' + token,
  522. },
  523. body: form_data,
  524. }).then(resjson => {
  525. return resjson.json();
  526. }).then(res => {
  527. const { data } = res;
  528. if (!imgall_values[queImgs[queImgsCindex].design_sku]) {
  529. imgall_values[queImgs[queImgsCindex].design_sku] = {
  530. }
  531. }
  532. if (!imgall_values[queImgs[queImgsCindex].design_sku][queImgs[queImgsCindex].design_pic]) {
  533. imgall_values[queImgs[queImgsCindex].design_sku][queImgs[queImgsCindex].design_pic] = {
  534. ...data
  535. }
  536. }
  537. if (imgall_values[queImgs[queImgsCindex].design_sku][queImgs[queImgsCindex].design_pic]) {
  538. imgall_values[queImgs[queImgsCindex].design_sku][queImgs[queImgsCindex].design_pic] = {
  539. ...data
  540. }
  541. }
  542. queImgsCindex++
  543. imgUpdate()
  544. }).catch(error => {
  545. queImgsCindex++
  546. imgUpdate()
  547. })
  548. })
  549. } else {
  550. for (let key in table_obj) {
  551. if (imgall_values[key]) {
  552. // 定制图
  553. if (table_obj[key].data_params && Array.isArray(table_obj[key].data_params) && table_obj[key].data_params.length) {
  554. const design_pic = table_obj[key].data_params.find((item: any) => item.design_pic)
  555. if (design_pic) {
  556. table_obj[key].data_params.map((item: any) => {
  557. if (item.design_pic && imgall_values[key][item.design_pic]) {
  558. const { width, height, url, type } = imgall_values[key][item.design_pic]
  559. item['width'] = width
  560. item['height'] = height
  561. item['file'] = url
  562. item['type'] = type
  563. // console.log(item)
  564. }
  565. return item
  566. })
  567. }
  568. }
  569. // 预览图
  570. if (isPreImg == 1) {
  571. if (table_obj[key].pre_info && table_obj[key].pre_info.pre_pic && imgall_values[key][table_obj[key].pre_info.pre_pic]) {
  572. const { width, height, url, type } = imgall_values[key][table_obj[key].pre_info.pre_pic]
  573. table_obj[key].pre_info = {
  574. ...table_obj[key].pre_info,
  575. width,
  576. height,
  577. file: url,
  578. type,
  579. }
  580. }
  581. }
  582. }
  583. }
  584. // console.log(imgall_values, '-imgall_values', table_obj)
  585. imgFetchFun(table_obj)
  586. }
  587. }
  588. imgUpdate()
  589. return
  590. }
  591. function imgFetchFun(table_obj: any) {
  592. const table_params = Object.values(table_obj)
  593. let arr_index = 0
  594. const FetchFun = (params: any) => {
  595. params['api_token'] = token
  596. fetch(fetch_url, {
  597. method: 'POST',
  598. headers: {
  599. 'Content-Type': 'application/json',
  600. },
  601. body: JSON.stringify(params),
  602. }).then(resjson => {
  603. return resjson.json();
  604. }).then(res => {
  605. if (res.data.error && res.data.error.length) {
  606. // 未上传成功的 图片
  607. console.log(res.data.error, "arr_index", arr_index)
  608. res.data.error.forEach((item: any) => {
  609. CustomMessage.error(item.design_pic)
  610. })
  611. }
  612. // tableData循环出备货单相同的数据,修改表格操作数据 is_upload
  613. let tableData1 = tableData.map(item => {
  614. if (item.order_no == params.order_no) {
  615. // console.log(item.order_no, "item.order_no", params)
  616. item.is_upload = true
  617. }
  618. // console.log(errImgDatas, "errImgDatas")
  619. errImgDatas.forEach((items) => {
  620. // 定制图上传失败
  621. if (items.design_pic == item.design_pic) {
  622. // 429错误
  623. item.is_upload = false
  624. item.is_error = true
  625. }
  626. // 预览图上传失败 概率小速度慢暂时不做处理
  627. // if (isPreImg == 1) {
  628. // if (items.design_pic == item.pre_info.pre_pic) {
  629. // item.is_upload = false
  630. // item.is_error = true
  631. // }
  632. // }
  633. })
  634. return item
  635. })
  636. setTableData(tableData1)
  637. arr_index++
  638. if (arr_index < table_params.length) {
  639. // console.log(tableData1,"tableData111")
  640. FetchFun(table_params[arr_index])
  641. } else {
  642. setLoading(false)
  643. setTableData(tableData.filter(item => !item.is_upload))
  644. setErrImgDatas([])
  645. CustomMessage.success("图片上传结束")
  646. }
  647. }).catch(err => {
  648. // console.log(err, "err")
  649. arr_index++
  650. if (arr_index < table_params.length) {
  651. FetchFun(table_params[arr_index])
  652. } else {
  653. setLoading(false)
  654. setTableData(tableData.filter(item => !item.is_upload))
  655. setErrImgDatas([])
  656. CustomMessage.success("图片上传结束")
  657. }
  658. })
  659. }
  660. setLoading(true)
  661. FetchFun(table_params[arr_index])
  662. }
  663. imgFetchFun(table_obj)
  664. } catch (error) {
  665. console.error(error, "报错")
  666. }
  667. }
  668. const evChangeRadio = (e: any) => {
  669. let ev = e && e.target ? e.target.value : e
  670. setIsPreImg(ev)
  671. }
  672. return (
  673. <Loading visible={loading} fullScreen>
  674. <div className='w-3xl h-fit'>
  675. <Button
  676. type="primary"
  677. disabled={isPage || btnLoading}
  678. style={{ marginBottom: '10px', marginRight: '10px' }}
  679. onClick={() => {
  680. getPicData()
  681. }}>获取定制数据</Button>
  682. <Button
  683. disabled={(!tableData.length) || isPage || btnLoading}
  684. type="primary"
  685. style={{ marginBottom: '10px', marginRight: '10px' }}
  686. onClick={() => {
  687. uploadPic()
  688. }}>上传定制信息</Button>
  689. <span className='text-red-500'>ps:需在Temu定制商品内容页面获取数据,且上传图片过程中请勿关闭插件</span>
  690. <div className='flex items-center' style={{ marginBottom: '10px' }}>
  691. <p style={{ fontSize: 14, marginBottom: 0, marginRight: 5 }}>是否获取合成预览图: </p>
  692. <RadioGroup value={isPreImg} onChange={(e) => {
  693. evChangeRadio(e)
  694. }} aria-labelledby="groupId">
  695. <Radio value={1}>
  696. </Radio>
  697. <Radio value={-1}>
  698. </Radio>
  699. </RadioGroup>
  700. </div>
  701. <Table dataSource={dataSourceWithIndex}>
  702. <Table.Column title="序号" cell={order_render} align="center" />
  703. <Table.Column title="备货单" cell={name_render} align="center" />
  704. {
  705. isPreImg == 1 && <Table.Column title="合成预览图" cell={design_render} align="center" />
  706. }
  707. <Table.Column title="定制区域" cell={label_render} align="center" />
  708. <Table.Column title="文字" cell={text_render} align="center" />
  709. <Table.Column title="图片" cell={pic_render} align="center" />
  710. <Table.Column title={<div className='flex justify-center items-center'>
  711. <div>操作</div><Balloon v2 closable={false} trigger={<a><IconCom type="info" _style={{cursor:'pointer', marginLeft: 5}} /></a>} align="t" triggerType="hover" style={{ width: 300 }}>
  712. 图片上传失败时,请重新点击上传定制信息按钮
  713. </Balloon>
  714. </div>} cell={option_render} align="center" />
  715. </Table>
  716. <p className='text-red-500'>ps:若获取不到数据,可能是插件未连接成功,请刷新页面</p>
  717. </div>
  718. </Loading>
  719. )
  720. }