shaogen1995 2 miesięcy temu
rodzic
commit
d3bc572e81

+ 3 - 0
src/assets/styles/base.css

@@ -314,3 +314,6 @@ textarea {
 #root .Z0ku .anticon-down {
   color: #fff;
 }
+#root .Z0ku .Z0kuTxt {
+  color: var(--txtColor);
+}

+ 3 - 0
src/assets/styles/base.less

@@ -396,5 +396,8 @@ textarea {
     .anticon-down {
       color: #fff;
     }
+    .Z0kuTxt {
+      color: var(--txtColor);
+    }
   }
 }

+ 1 - 1
src/components/Z0sonTable/index.tsx

@@ -36,7 +36,7 @@ function Z0sonTable({
   onChange,
   staBtn = [],
   classKey = '',
-  filArr = ['排序值', '入库状态', '发布状态', '推荐状态', '附件', '大封面'],
+  filArr = ['排序值', '入库状态', '发布状态', '推荐状态', '附件', '大封面', '关联资源'],
   tabBtnArrAll
 }: Props) {
   useEffect(() => {

+ 6 - 4
src/pages/Bresource/B1overview/index.tsx

@@ -47,8 +47,10 @@ function B1overview() {
       if (data && data.length) {
         setKuList(data)
         const ziyuanAcTxt = ziyuanAcGet()
+        let objRes = data.find(v => v.value === ziyuanAcTxt)
 
-        const fId = ziyuanAcTxt || data[0].value
+        const resFid = objRes ? ziyuanAcTxt : data[0].value
+        const fId = resFid
         const obj = { ...selectTopBase, formDefId: fId }
         setFormData(obj)
         getFormZiFu(fId)
@@ -180,13 +182,13 @@ function B1overview() {
               >
                 查看
               </Button>
-              {[2, 3].includes(item.status_storage) ? (
+              {item.status_storage === 3 ? (
                 <Button size='small' type='text' onClick={() => tableBtnFu('二维码', item.id)}>
                   二维码
                 </Button>
-              ) : (
+              ) : item.status_storage === 1 ? (
                 <MyPopconfirm txtK='删除' onConfirm={() => tableBtnFu('删除', item.id)} />
-              )}
+              ) : null}
             </>
           )
         }

+ 20 - 0
src/pages/Zother/AddGood/AddZiYuan/index.module.scss

@@ -0,0 +1,20 @@
+.AddZiYuan {
+  :global {
+    .ant-modal-close {
+      display: none;
+    }
+    .ant-modal-body {
+      border-top: 1px solid #ccc;
+    }
+    .AZmain {
+      padding-top: 15px;
+      .AZRow {
+        margin-bottom: 5px;
+      }
+      .AZbtn {
+        margin-top: 20px;
+        text-align: center;
+      }
+    }
+  }
+}

+ 51 - 0
src/pages/Zother/AddGood/AddZiYuan/index.tsx

@@ -0,0 +1,51 @@
+import React, { useCallback, useState } from 'react'
+import styles from './index.module.scss'
+import { Button, Checkbox, Modal } from 'antd'
+
+type Props = {
+  closeFu: () => void
+  secletFu: (val: number) => void
+  kuList: any[]
+}
+
+function AddZiYuan({ closeFu, kuList, secletFu }: Props) {
+  const [num, setNum] = useState(0)
+
+  // 点击确定
+  const btnOk = useCallback(() => {
+    closeFu()
+    secletFu(num)
+  }, [closeFu, num, secletFu])
+
+  return (
+    <Modal
+      getContainer={() => document.querySelector('#root')!}
+      wrapClassName={styles.AddZiYuan}
+      open={true}
+      title='选择资源表'
+      footer={
+        [] // 设置footer为空,去掉 取消 确定默认按钮
+      }
+    >
+      <div className='AZmain'>
+        {kuList.map(item => (
+          <div className='AZRow' key={item.value}>
+            <Checkbox checked={num === item.value} onChange={() => setNum(item.value)}>
+              {item.label}
+            </Checkbox>
+          </div>
+        ))}
+        <div className='AZbtn'>
+          <Button type='primary' disabled={!num} onClick={btnOk}>
+            确定
+          </Button>
+          &emsp;<Button onClick={closeFu}>关闭</Button>
+        </div>
+      </div>
+    </Modal>
+  )
+}
+
+const MemoAddZiYuan = React.memo(AddZiYuan)
+
+export default MemoAddZiYuan

+ 37 - 3
src/pages/Zother/AddGood/index.tsx

@@ -10,15 +10,19 @@ import Z3upFiles from '@/components/Z3upFiles'
 import { treeOneIdByResFu } from '../Z1formSet/data'
 import { useSelector } from 'react-redux'
 import { RootState } from '@/store'
+import AddZiYuan from './AddZiYuan'
+import SelectGoods from '../SelectGoods'
+import { C1_APIgetGoodsListByFaBu } from '@/store/action/CinStorage/C1resIn'
 type Props = {
   sId: number
   closeFu: () => void
   succFu: (val: '新增' | '编辑', obj: any) => void
   formZi: baseFormType[]
   formDefId: number
+  kuList: any[]
 }
 
-function AddGood({ formDefId, sId, closeFu, succFu, formZi }: Props) {
+function AddGood({ formDefId, sId, closeFu, succFu, formZi, kuList }: Props) {
   // 级联选择
   const jiLianKey = useMemo(() => {
     return formZi.filter(v => ['关联标签', '关联字典'].includes(v.tag)).map(c => c.fieldName)
@@ -132,6 +136,11 @@ function AddGood({ formDefId, sId, closeFu, succFu, formZi }: Props) {
   // 关联标签
   const biaoQianTemp = useSelector((state: RootState) => state.B3resTag.dictAll)
 
+  // 点击关联资源
+  const [ziYuan, setZiYuan] = useState(false)
+
+  const [ziYuanId, setZiYuanId] = useState(0)
+
   return (
     <Modal
       getContainer={() => document.querySelector('#root')!}
@@ -180,8 +189,9 @@ function AddGood({ formDefId, sId, closeFu, succFu, formZi }: Props) {
                       myUrl='cms/form/data/upload'
                     />
                   ) : item.fieldLabel === '关联资源' ? (
-                    // 待完善关联资源
-                    <Button type='primary'>关联资源</Button>
+                    <Button type='primary' onClick={() => setZiYuan(true)}>
+                      关联资源
+                    </Button>
                   ) : null}
                 </div>
               </div>
@@ -245,6 +255,30 @@ function AddGood({ formDefId, sId, closeFu, succFu, formZi }: Props) {
           </Form.Item>
         </Form>
       </div>
+
+      {/* 点击关联资源 */}
+      {ziYuan ? (
+        <AddZiYuan
+          closeFu={() => setZiYuan(false)}
+          secletFu={val => setZiYuanId(val)}
+          kuList={kuList}
+        />
+      ) : null}
+
+      {/* 待完善 */}
+      {ziYuanId ? (
+        <SelectGoods
+          API_getList={C1_APIgetGoodsListByFaBu}
+          closeFu={() => setZiYuanId(0)}
+          dataResFu={data => {
+            console.log('-------', data)
+          }}
+          oldCheckArr={[]}
+          formDefId={ziYuanId}
+          kuList={kuList}
+          formZi={formZi}
+        />
+      ) : null}
     </Modal>
   )
 }

+ 7 - 7
src/pages/Zother/SelectGoods/data.tsx

@@ -85,14 +85,14 @@ export const tableColumns = (
       if (['文本', '数字'].includes(v.tag)) txt = tableTxtRes(item[v.fieldName])
       else if (['关联字典', '关联标签'].includes(v.tag)) {
         txt = dictIdByName(item[v.fieldName])
-      } else if (v.tag === '关联资源') {
-        // 待完善
-        if (item.form_ids) {
-          const arr: any[] = item.form_ids.split(',')
-          const arrTemp = kuList.filter(v => arr.includes(v.value + '')).map(c => c.label)
-          txt = arrTemp.join(' / ')
-        }
       }
+      // else if (v.tag === '关联资源') {
+      //   if (item.form_ids) {
+      //     const arr: any[] = item.form_ids.split(',')
+      //     const arrTemp = kuList.filter(v => arr.includes(v.value + '')).map(c => c.label)
+      //     txt = arrTemp.join(' / ')
+      //   }
+      // }
       return txt
     }
   }))

+ 5 - 36
src/pages/Zother/SelectGoods/index.tsx

@@ -8,10 +8,9 @@ import { selectTopBase } from './data'
 import { useSelector } from 'react-redux'
 import { RootState } from '@/store'
 import { treeOneIdByResFu } from '../Z1formSet/data'
-import { antdSelectType } from '@/utils/dataChange'
+import { antdSelectType, tableSelectToTxt } from '@/utils/dataChange'
 import Z0sonTable from '@/components/Z0sonTable'
 import { baseFormType } from '@/pages/Zsystem/Z1sysSet/data'
-import { Z1_APIgetFormZiDuan } from '@/store/action/Zsystem/Z1sysSet'
 import { baseFilter } from '@/pages/Zuse/UseFormZi'
 
 type Props = {
@@ -21,10 +20,9 @@ type Props = {
   oldCheckArr: GoodsType[]
   formDefId: number
   kuList: antdSelectType[]
-  formZiTemp: baseFormType[]
+  formZi: baseFormType[]
   isOne?: boolean // 单选
   canObj?: any //其他额外的参数
-  isKu?: boolean
 }
 
 function SelectGoods({
@@ -34,27 +32,10 @@ function SelectGoods({
   formDefId,
   oldCheckArr,
   kuList,
-  formZiTemp,
+  formZi,
   isOne,
-  canObj,
-  isKu = false
+  canObj
 }: Props) {
-  // 获取表单字段
-  const [formZi, setFormZi] = useState<baseFormType[]>([])
-
-  const getFormZiFu = useCallback(async (id: number) => {
-    // 获取表单字段
-    const res = await Z1_APIgetFormZiDuan(id)
-    if (res.code === 0) {
-      const list: any[] = res.data || {}
-      setFormZi(list)
-    }
-  }, [])
-
-  useEffect(() => {
-    setFormZi(formZiTemp)
-  }, [formZiTemp])
-
   const [formData, setFormData] = useState({ ...selectTopBase, formDefId })
   const formDataRef = useRef({ ...selectTopBase, formDefId })
 
@@ -220,19 +201,7 @@ function SelectGoods({
           <div>
             选择资源 &emsp;
             <div className='Z0ku'>
-              资源库:
-              <Select
-                // 待完善 跨资源库选资源--id有相同的 并且 选中条数 数据有问题
-                disabled={!isKu}
-                style={{ minWidth: 120, opacity: isKu ? 1 : 0.6 }}
-                options={kuList}
-                value={formData.formDefId}
-                onChange={e => {
-                  setFormData({ ...formData, formDefId: e })
-                  getFormZiFu(e)
-                  resetSelectFu(e)
-                }}
-              />
+              资源库:<span className='Z0kuTxt'>{tableSelectToTxt(Number(formDefId), kuList)}</span>
             </div>
           </div>
           <div>已选中 {resNum} 条</div>

+ 2 - 1
src/pages/Zother/Z0edit/index.tsx

@@ -499,7 +499,7 @@ function Z0edit({ pageKey, APIobj, topArr, selectTxt, selcctOne = false }: Props
           oldCheckArr={snaps}
           formDefId={openSelect}
           kuList={kuList}
-          formZiTemp={formZi}
+          formZi={formZi}
           isOne={selcctOne}
         />
       ) : null}
@@ -507,6 +507,7 @@ function Z0edit({ pageKey, APIobj, topArr, selectTxt, selcctOne = false }: Props
       {/* 新增/编辑 资源 */}
       {editId ? (
         <AddGood
+          kuList={kuList}
           sId={editId}
           closeFu={() => setEditId(0)}
           succFu={(val, obj) => {

+ 5 - 1
src/pages/Zother/Z0table/index.tsx

@@ -39,7 +39,11 @@ function Z0table({ topSearchArr, getListAPI, pageKey, yHeight = 660, tableInfo }
 
         const ziyuanAcTxt = ziyuanAcGet()
 
-        const obj = { ...baseForm, formDefId: ziyuanAcTxt || data[0].value }
+        let objRes = data.find(v => v.value === ziyuanAcTxt)
+
+        const resFid = objRes ? ziyuanAcTxt : data[0].value
+
+        const obj = { ...baseForm, formDefId: resFid }
         setFormData(obj)
         dispatch(getListAPI(obj))
       }

+ 1 - 1
src/pages/Zother/Z2addForm/index.tsx

@@ -50,7 +50,7 @@ function Z2addForm({ sId, oldInfo, closeFu, upInfoFu }: Props) {
               ? Number(values.dictId2)
               : null,
         isDict: ['关联字典', '关联标签'].includes(tag!) ? 1 : tag === '文本' ? 2 : 0,
-        fieldType: ['数字'].includes(tag!) ? 'number' : 'text',
+        fieldType: ['数字'].includes(tag!) ? 'number' : tag === '关联资源' ? 'longtext' : 'text',
         formDefId: sId,
         options: '',
         queryType,

+ 18 - 2
src/pages/Zother/ZgoodsInfo/index.tsx

@@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'
 import styles from './index.module.scss'
 import { APIgetFileList, APIgetGoodsInfo } from '@/store/action/Bresource/B1overview'
 import { useParams } from 'react-router-dom'
-import { selectObj } from '@/utils/dataChange'
+import { antdSelectType, selectObj } from '@/utils/dataChange'
 import { Button, Dropdown } from 'antd'
 import classNames from 'classnames'
 import { MessageFu } from '@/utils/message'
@@ -14,9 +14,24 @@ import AddGood from '../AddGood'
 import { FileListType } from '@/components/Z3upFiles/data'
 import Zg2file from './Zg2file'
 import Zg3log from './Zg3log'
+import { getKuListByOpenFu } from '../data'
 
 function ZgoodsInfo() {
   const { id, fId } = useParams<any>()
+
+  const [kuTxt, setkuTxt] = useState('')
+  const [kuList, setKuList] = useState<antdSelectType[]>([])
+
+  useEffect(() => {
+    getKuListByOpenFu(data => {
+      if (data && data.length) {
+        setKuList(data)
+        const obj = data.find(v => v.value === Number(fId))
+        if (obj) setkuTxt(obj.label)
+      }
+    }, true)
+  }, [fId])
+
   // 获取表单字段
   const { formZi } = UseFormZi(fId)
 
@@ -144,7 +159,7 @@ function ZgoodsInfo() {
   }, [info.id])
   return (
     <div className={styles.ZgoodsInfo}>
-      <div className='pageTitle'>资源详情</div>
+      <div className='pageTitle'>资源详情&emsp;资源库:{kuTxt}</div>
       {info.id ? (
         <>
           <div className='ZGtop1'>
@@ -199,6 +214,7 @@ function ZgoodsInfo() {
       {/* 新增/编辑 资源 */}
       {editId ? (
         <AddGood
+          kuList={kuList}
           sId={editId}
           closeFu={() => setEditId(0)}
           succFu={(val, obj) => getInfoFu()}

+ 2 - 2
src/pages/Zother/data.tsx

@@ -34,11 +34,11 @@ export type Typetable = {
 export type GoodsType = any
 
 // 异步获取资源库列表--已开启状态
-export const getKuListByOpenFu = async (back: (data: any[]) => void) => {
+export const getKuListByOpenFu = async (back: (data: any[]) => void, all?: boolean) => {
   const res = await Z1_APIgetAll({ pageNum: 1, pageSize: 99999 }, true)
   if (res.code === 0) {
     let list: any[] = res.data.records || []
-    list = list.filter(v => v.isEnabled === 1).map(v => ({ value: v.id, label: v.formName }))
+    list = list.filter(v => v.isEnabled === 1 || all).map(v => ({ value: v.id, label: v.formName }))
     back(list)
   }
 }

+ 2 - 0
src/pages/Zsystem/Z1sysSet/index.tsx

@@ -39,6 +39,7 @@ function Z1sysSet() {
       const res: any = await Z1_APIdel(item.id)
       if (res.code === 0) {
         MessageFu.success('删除成功!')
+        // changeZiYuanFu(item.id)
         getList()
       }
     },
@@ -53,6 +54,7 @@ function Z1sysSet() {
     async (id: number, val: boolean) => {
       const res = await Z1_APIswitch(id, val ? 1 : 0)
       if (res.code === 0) {
+        // if (!val) changeZiYuanFu(id)
         MessageFu.success('操作成功')
         getList()
       }

+ 7 - 0
src/store/action/CinStorage/C1resIn.ts

@@ -33,6 +33,13 @@ export const C1_APIgetGoodsList = (data: any) => {
   return http.post('cms/orderRk/getResourceList', data)
 }
 
+/**
+ * 关联资源-从已发布资源中选择
+ */
+export const C1_APIgetGoodsListByFaBu = (data: any) => {
+  return http.post('cms/orderRk/getRelevanceList', data)
+}
+
 export type APItxtType =
   | '创建订单'
   | '获取详情'

+ 7 - 1
src/utils/storage.ts

@@ -49,7 +49,13 @@ export const ziyuanAcSet = (id: number) => {
 // 取
 export const ziyuanAcGet = () => {
   let res = 0
-  let txt = localStorage.getItem(GOODPAGE_KEY) || ''
+  let txt = localStorage.getItem(GOODPAGE_KEY) || '0'
   if (txt) res = Number(txt)
   return res
 }
+
+// 关闭 或者删除 表单的时候 需要特殊处理
+export const changeZiYuanFu = (id: number) => {
+  const id2 = ziyuanAcGet()
+  if (id2 === id) ziyuanAcSet(0)
+}