فهرست منبع

准备开始写新增

shaogen1995 2 ماه پیش
والد
کامیت
8f9b8e44bd

+ 23 - 1
src/assets/styles/base.css

@@ -87,6 +87,16 @@ textarea {
   display: flex;
   justify-content: center;
 }
+#root .ant-table-cell {
+  min-width: 100px;
+}
+#root .ant-table-cell:has(.tableAuto) {
+  min-width: auto;
+}
+#root .tableAuto .ant-checkbox-wrapper {
+  display: flex;
+  justify-content: center;
+}
 #root .ant-image {
   display: none;
 }
@@ -162,7 +172,7 @@ textarea {
 }
 .ant-table-header .ant-table-cell {
   color: #fff !important;
-  background-color: rgba(132, 44, 29, 0.8) !important;
+  background-color: #9d564a !important;
 }
 .ant-table-body .ant-table-cell {
   border-color: #ccc !important;
@@ -287,3 +297,15 @@ textarea {
   font-size: 24px;
   font-weight: 700;
 }
+#root .Z0ku {
+  font-weight: 400;
+}
+#root .Z0ku .ant-select-selector {
+  background-color: var(--txtColor);
+}
+#root .Z0ku .ant-select-selector .ant-select-selection-item {
+  color: #fff;
+}
+#root .Z0ku .anticon-down {
+  color: #fff;
+}

+ 30 - 1
src/assets/styles/base.less

@@ -119,6 +119,20 @@ textarea {
     justify-content: center;
   }
 
+  .ant-table-cell {
+    min-width: 100px;
+    &:has(.tableAuto) {
+      min-width: auto;
+    }
+  }
+
+  .tableAuto {
+    .ant-checkbox-wrapper {
+      display: flex;
+      justify-content: center;
+    }
+  }
+
   /* antd图片预览组件 */
   .ant-image {
     display: none;
@@ -216,7 +230,7 @@ textarea {
 .ant-table-header {
   .ant-table-cell {
     color: #fff !important;
-    background-color: rgba(132, 44, 29, 0.8) !important;
+    background-color: #9d564a !important;
   }
 }
 
@@ -364,3 +378,18 @@ textarea {
   font-size: 24px;
   font-weight: 700;
 }
+
+#root {
+  .Z0ku {
+    font-weight: 400;
+    .ant-select-selector {
+      background-color: var(--txtColor);
+      .ant-select-selection-item {
+        color: #fff;
+      }
+    }
+    .anticon-down {
+      color: #fff;
+    }
+  }
+}

+ 16 - 0
src/components/Z0sonTable/index.module.scss

@@ -0,0 +1,16 @@
+.Z0sonTable {
+  :global {
+    .ant-table-cell {
+      padding: 8px !important;
+    }
+  }
+}
+.Z0sonTableHide {
+  :global {
+    .ant-table-cell-scrollbar {
+      width: 15px !important;
+      padding: 0px !important;
+      min-width: 0px !important;
+    }
+  }
+}

+ 115 - 0
src/components/Z0sonTable/index.tsx

@@ -0,0 +1,115 @@
+import React, { useCallback, useEffect } from 'react'
+import styles from './index.module.scss'
+import { Button, Empty, Table } from 'antd'
+import { tableColumns } from '../../pages/Zother/SelectGoods/data'
+import { antdSelectType } from '@/utils/dataChange'
+import { baseFormType } from '@/pages/Zsystem/Z1sysSet/data'
+import { openLink } from '@/utils/history'
+import classNames from 'classnames'
+
+type Props = {
+  kuList: antdSelectType[]
+  formZi: baseFormType[]
+  tableList: any[]
+  pageInfo?: { current: number; size: number; total: number }
+  yHeight?: number
+  onChange?: (pageNum: number, pageSize: number) => void
+  endBtn?: any[]
+  staBtn?: any[]
+  filArr?: string[]
+  classKey?: string
+}
+
+function Z0sonTable({
+  kuList,
+  formZi,
+  tableList,
+  pageInfo,
+  yHeight,
+  onChange,
+  staBtn = [],
+  classKey = '',
+  endBtn = [],
+  filArr = ['排序值', '入库状态', '发布状态', '推荐状态', '附件', '大封面']
+}: Props) {
+  useEffect(() => {
+    if (tableList && tableList.length) {
+      const dom = document.querySelector(`.Z0sonTable${classKey} .ant-table-body`) as HTMLDivElement
+
+      if (dom && yHeight) dom.style.height = yHeight + 'px'
+    }
+  }, [classKey, tableList, yHeight])
+
+  // 页码变化
+  const paginationChange = useCallback(
+    () => (pageNum: number, pageSize: number) => {
+      if (onChange) onChange(pageNum, pageSize)
+    },
+    [onChange]
+  )
+
+  return (
+    <>
+      {tableList && tableList.length ? (
+        <div
+          className={classNames(
+            `${styles.Z0sonTable} Z0sonTable${classKey}`,
+            yHeight ? '' : styles.Z0sonTableHide
+          )}
+          id='Z0sonTable'
+        >
+          <Table
+            rowKey='id'
+            columns={tableColumns(
+              kuList,
+              staBtn,
+              formZi,
+              [
+                {
+                  title: '操作',
+                  width: 100,
+                  fixed: 'right',
+                  render: (item: any) => (
+                    <Button
+                      size='small'
+                      type='text'
+                      onClick={() => openLink(`/goodsLook/${item.id}`)}
+                    >
+                      查看
+                    </Button>
+                  )
+                },
+                ...endBtn
+              ],
+              filArr
+            )}
+            dataSource={tableList}
+            scroll={{ x: 'max-content', y: yHeight || 'auto' }}
+            pagination={
+              pageInfo
+                ? {
+                    showQuickJumper: true,
+                    position: ['bottomCenter'],
+                    showSizeChanger: true,
+                    current: pageInfo.current,
+                    pageSize: pageInfo.size,
+                    total: pageInfo.total,
+                    onChange: paginationChange()
+                  }
+                : false
+            }
+          />
+        </div>
+      ) : (
+        <Empty
+          style={{ height: yHeight ? yHeight + 81 + 'px' : 'auto' }}
+          image={Empty.PRESENTED_IMAGE_SIMPLE}
+        />
+      )}
+    </>
+  )
+}
+
+const MemoZ0sonTable = React.memo(Z0sonTable)
+
+export default MemoZ0sonTable

+ 0 - 5
src/pages/Zother/SelectGoods/data.ts

@@ -1,5 +0,0 @@
-export const selectTopBase = {
-  searchKey: '',
-  current: 1,
-  size: 10
-}

+ 87 - 0
src/pages/Zother/SelectGoods/data.tsx

@@ -0,0 +1,87 @@
+import ImageLazy from '@/components/ImageLazy'
+import { dictIdByName } from '@/utils'
+import { antdSelectType } from '@/utils/dataChange'
+
+export const selectTopBase: any = {
+  searchKey: '',
+  current: 1,
+  size: 10
+}
+
+// 动态表单展示
+export const tableColumns = (
+  kuList: antdSelectType[],
+  arr0: any[] = [],
+  arr2Temp: any[] = [],
+  arr3: any[] = [],
+  filArrTemp: string[] = []
+) => {
+  const arr1: any[] = [
+    {
+      title: '资源编码',
+      width: 100,
+      fixed: 'left',
+      render: (item: any) => item.num || '(空)'
+    },
+    {
+      title: '资源名称',
+      width: 100,
+      fixed: 'left',
+      render: (item: any) => item.name || '(空)'
+    },
+    {
+      title: '责任者',
+      width: 100,
+      fixed: 'left',
+      render: (item: any) => item.create_by || '(空)'
+    },
+    {
+      title: '封面',
+      width: 80,
+      fixed: 'left',
+      render: (item: any) => (
+        <div className='tableImgAuto'>
+          <ImageLazy
+            width={60}
+            height={60}
+            src={item.thumb || item.thumbPc}
+            srcBig={item.thumbPc || item.thumb}
+          />
+        </div>
+      )
+    },
+    {
+      title: '权限级',
+      width: 100,
+      fixed: 'left',
+      render: (item: any) => item.level_perm || '(空)'
+    }
+  ]
+
+  const filArr = arr1.map(c => c.title)
+  filArrTemp.forEach(v => {
+    filArr.push(v)
+  })
+
+  let arr2 = arr2Temp.filter(v => !filArr.includes(v.fieldLabel))
+
+  arr2 = arr2.map(v => ({
+    title: v.fieldLabel,
+    render: (item: any) => {
+      let txt: any = '(空)'
+      if (['文本', '数字'].includes(v.tag)) txt = 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(' / ')
+        }
+      }
+      return txt
+    }
+  }))
+
+  return [...arr0, ...arr1, ...arr2, ...arr3]
+}

+ 14 - 20
src/pages/Zother/SelectGoods/index.module.scss

@@ -3,7 +3,12 @@
   :global {
     .sgtit {
       display: flex;
+      align-items: center;
       justify-content: space-between;
+      & > div {
+        display: flex;
+        align-items: center;
+      }
     }
 
     .ant-modal-close {
@@ -22,39 +27,28 @@
 
     .sgMain {
       padding-top: 15px;
-      display: flex;
 
       .sgLeft {
-        margin-bottom: 15px;
-        width: 300px;
+        margin-bottom: 20px;
         position: relative;
-        padding-top: 40px;
+        display: flex;
+        justify-content: space-between;
 
         .sgLeft2 {
-          height: 650px;
-          overflow: auto;
+          overflow-x: auto;
+          display: inline-block;
+          white-space: nowrap;
+          width: calc(100% - 160px);
           .sgLeftRow {
-            width: 100%;
-            margin-bottom: 20px;
+            display: inline-block;
           }
         }
-
-        .sgLeftBtn {
-          position: absolute;
-          width: 100%;
-          top: 0;
-          left: 0;
-          text-align: center;
-        }
       }
       .sgRight {
-        padding-left: 10px;
-        border-left: 1px solid #ccc;
-        margin-left: 10px;
-        width: calc(100% - 320px);
         .ant-table-cell {
           padding: 8px !important;
           text-align: center !important;
+          // min-width: 100px !important;
         }
         .ant-btn-text {
           color: var(--themeColor);

+ 122 - 49
src/pages/Zother/SelectGoods/index.tsx

@@ -1,12 +1,16 @@
 import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
 import styles from './index.module.scss'
 import { GoodsType } from '../data'
-import { Button, Checkbox, Input, Modal } from 'antd'
-import { openLink } from '@/utils/history'
+import { Button, Cascader, Checkbox, Input, Modal, Select } from 'antd'
 import { MessageFu } from '@/utils/message'
 import MyPopconfirm from '@/components/MyPopconfirm'
-import MyTable from '@/components/MyTable'
 import { selectTopBase } from './data'
+import { useSelector } from 'react-redux'
+import { RootState } from '@/store'
+import { treeOneIdByResFu } from '../Z1formSet/data'
+import { antdSelectType } from '@/utils/dataChange'
+import Z0sonTable from '@/components/Z0sonTable'
+import { baseFormType } from '@/pages/Zsystem/Z1sysSet/data'
 
 type Props = {
   API_getList: any
@@ -14,8 +18,12 @@ type Props = {
   dataResFu: (data: GoodsType[]) => void
   oldCheckArr: GoodsType[]
   formDefId: number
+  kuList: antdSelectType[]
+  formBi: baseFormType[]
+  formZi: baseFormType[]
   isOne?: boolean // 单选
   canObj?: any //其他额外的参数
+  isKu?: boolean
 }
 
 function SelectGoods({
@@ -24,11 +32,15 @@ function SelectGoods({
   dataResFu,
   formDefId,
   oldCheckArr,
+  kuList,
+  formBi,
+  formZi,
   isOne,
-  canObj
+  canObj,
+  isKu = false
 }: Props) {
-  const [formData, setFormData] = useState({ ...selectTopBase })
-  const formDataRef = useRef({ ...selectTopBase })
+  const [formData, setFormData] = useState({ ...selectTopBase, formDefId })
+  const formDataRef = useRef({ ...selectTopBase, formDefId })
 
   useEffect(() => {
     formDataRef.current = { ...formData }
@@ -46,12 +58,15 @@ function SelectGoods({
   }, [formData])
 
   // 点击重置
-  const resetSelectFu = useCallback(() => {
-    setFormData({ ...selectTopBase })
-    setTimeout(() => {
-      setTimeKey(Date.now())
-    }, 50)
-  }, [])
+  const resetSelectFu = useCallback(
+    (formDefId?: number) => {
+      setFormData({ ...selectTopBase, formDefId: formDefId || formData.formDefId })
+      setTimeout(() => {
+        setTimeKey(Date.now())
+      }, 50)
+    },
+    [formData.formDefId]
+  )
 
   const [total, setTotal] = useState(0)
   const [tableList, setTableList] = useState<GoodsType[]>([])
@@ -62,13 +77,19 @@ function SelectGoods({
     let canObjTemp = canObj || {}
     const obj = {
       ...formDataRef.current,
-      ...canObjTemp,
-      formDefId,
-      // 待完善
-      queryParams: {},
-      searchKey: ''
+      ...canObjTemp
     }
 
+    // 字典和标签需要 取最后一级 转成数字
+    const sonObj = { ...(obj.queryParams || {}) }
+
+    for (const k in sonObj) {
+      const temp = sonObj[k]
+      if (typeof temp === 'object') sonObj[k] = Number(temp[temp.length - 1])
+    }
+
+    obj.queryParams = sonObj
+
     // 第一次进来,获取到所有数据
     if (timeKey === 0) obj.size = 99999
 
@@ -84,7 +105,7 @@ function SelectGoods({
       setTotal(res.data.total)
       setTableList(resArr)
     }
-  }, [API_getList, canObj, formDefId, timeKey])
+  }, [API_getList, canObj, timeKey])
 
   useEffect(() => {
     getList()
@@ -125,31 +146,19 @@ function SelectGoods({
       {
         title: isOne ? '单选' : '选择',
         width: 50,
+        fixed: 'left',
         render: (item: GoodsType) => (
-          <Checkbox
-            checked={checkArr.map(v => v.id).includes(item.id)}
-            onChange={() => checkFu(item)}
-          ></Checkbox>
+          <div className='tableAuto'>
+            <Checkbox
+              checked={checkArr.map(v => v.id).includes(item.id)}
+              onChange={() => checkFu(item)}
+            ></Checkbox>
+          </div>
         )
       }
     ]
   }, [checkArr, checkFu, isOne])
 
-  const tableLastBtn = useMemo(() => {
-    return [
-      {
-        title: '操作',
-        render: (item: GoodsType) => {
-          return (
-            <Button size='small' type='text' onClick={() => openLink(`/goodsLook/${item.id}`)}>
-              查看
-            </Button>
-          )
-        }
-      }
-    ]
-  }, [])
-
   // 点击提交
   const btnOk = useCallback(() => {
     dataResFu(checkArr)
@@ -168,6 +177,21 @@ function SelectGoods({
     [formData]
   )
 
+  // 动态表单的渲染
+  const dongFormChange = useCallback(
+    (key: any, val: any) => {
+      const oldFormSon = { ...(formData.queryParams || {}) }
+      oldFormSon[key] = val
+      setFormData({ ...formData, queryParams: oldFormSon })
+    },
+    [formData]
+  )
+
+  // 关联字典数组
+  const dictArrTemp = useSelector((state: RootState) => state.Z2dict.dictAll)
+  // 关联标签
+  const biaoQianTemp = useSelector((state: RootState) => state.B3resTag.dictAll)
+
   return (
     <Modal
       getContainer={() => document.querySelector('#root')!}
@@ -175,7 +199,23 @@ function SelectGoods({
       open={true}
       title={
         <div className='sgtit'>
-          <div>选择资源</div> <div>已选中 {resNum} 条</div>
+          <div>
+            选择资源 &emsp;
+            <div className='Z0ku'>
+              资源库:
+              <Select
+                disabled={!isKu}
+                style={{ minWidth: 120, opacity: isKu ? 1 : 0.6 }}
+                options={kuList}
+                value={formData.formDefId}
+                onChange={e => {
+                  setFormData({ ...formData, formDefId: e })
+                  resetSelectFu(e)
+                }}
+              />
+            </div>
+          </div>
+          <div>已选中 {resNum} 条</div>
         </div>
       }
       footer={[]}
@@ -185,6 +225,7 @@ function SelectGoods({
           <div className='sgLeft2'>
             <div className='sgLeftRow'>
               <Input
+                style={{ width: 300 }}
                 value={formData.searchKey}
                 onChange={e => setFormData({ ...formData, searchKey: e.target.value })}
                 placeholder='请输入资源编码、资源名称、责任者'
@@ -192,29 +233,61 @@ function SelectGoods({
                 showCount
               />
             </div>
+            {formBi.map(item => (
+              <div key={item.id} className='sgLeftRow'>
+                {item.tag === '文本' ? (
+                  <Input
+                    value={(formData.queryParams || {})[item.fieldName]}
+                    onChange={e => dongFormChange(item.fieldName, e.target.value.trim())}
+                    placeholder={item.fieldLabel}
+                    maxLength={30}
+                    showCount
+                  />
+                ) : ['关联标签', '关联字典'].includes(item.tag) ? (
+                  <Cascader
+                    changeOnSelect
+                    value={(formData.queryParams || {})[item.fieldName]}
+                    onChange={e => dongFormChange(item.fieldName, e)}
+                    fieldNames={{ label: 'name', value: 'id', children: 'children' }}
+                    options={treeOneIdByResFu(
+                      item.tag === '关联字典' ? dictArrTemp : biaoQianTemp,
+                      item.dictId + ''
+                    )}
+                    placeholder={item.fieldLabel}
+                  />
+                ) : item.tag === '下拉' ? (
+                  <Select
+                    allowClear
+                    value={(formData.queryParams || {})[item.fieldName]}
+                    onChange={e => dongFormChange(item.fieldName, e)}
+                    style={{ width: 120 }}
+                    options={item.options.split(',').map(v => ({ value: v, label: v }))}
+                    placeholder={item.fieldLabel}
+                  />
+                ) : null}
+              </div>
+            ))}
           </div>
           <div className='sgLeftBtn'>
             <Button type='primary' onClick={clickSearch}>
               查询
             </Button>
             &emsp;
-            <Button onClick={resetSelectFu}>重置</Button>
+            <Button onClick={() => resetSelectFu()}>重置</Button>
           </div>
         </div>
 
         <div className='sgRight'>
           {/* 表格 */}
-          <MyTable
-            yHeight={565}
-            classKey='SelectGoods'
-            list={tableList}
-            columnsTemp={[]}
-            staBtn={staBtn}
-            lastBtn={tableLastBtn}
-            pageNum={formData.current}
-            pageSize={formData.size}
-            total={total}
+          <Z0sonTable
+            kuList={kuList}
+            formZi={formZi}
+            tableList={tableList}
+            pageInfo={{ current: formData.current, size: formData.size, total: total }}
+            yHeight={540}
             onChange={(pageNum, pageSize) => paginationChange(pageNum, pageSize)}
+            staBtn={staBtn}
+            classKey='sgRight'
           />
 
           <div className='sgMainBtn'>

+ 19 - 15
src/pages/Zother/Z0edit/index.tsx

@@ -11,7 +11,7 @@ import {
   pageSkitFu,
   Typetable
 } from '../data'
-import { selectObj } from '@/utils/dataChange'
+import { antdSelectType, selectObj } from '@/utils/dataChange'
 import { Button, DatePicker, Input } from 'antd'
 import TextArea from 'antd/es/input/TextArea'
 import dayjs from 'dayjs'
@@ -22,6 +22,8 @@ import MyPopconfirm from '@/components/MyPopconfirm'
 import { editBtnShowFu } from '@/utils/authority'
 import AuditList from '../AuditList'
 import SelectGoods from '../SelectGoods'
+import Z0sonTable from '@/components/Z0sonTable'
+import { UseFormZi } from '@/pages/Zuse/UseFormZi'
 
 const verifyArr = [{ key: 'num', txt: '请输入申请编号' }]
 
@@ -251,11 +253,13 @@ function Z0edit({ pageKey, APIobj, topArr, selectTxt, selcctOne = false }: Props
   const [loding, setLoding] = useState(false)
 
   const [kuTxt, setkuTxt] = useState('')
+  const [kuList, setKuList] = useState<antdSelectType[]>([])
 
   useEffect(() => {
     getKuListByOpenFu(data => {
       setLoding(true)
       if (data && data.length) {
+        setKuList(data)
         const obj = data.find(v => v.value === Number(fId))
         if (obj) setkuTxt(obj.label)
       }
@@ -265,12 +269,14 @@ function Z0edit({ pageKey, APIobj, topArr, selectTxt, selcctOne = false }: Props
   // 打开资源选择弹窗
   const [openSelect, setOpenSelect] = useState(0)
 
+  // 获取表单字段
+  const { formBi, formZi } = UseFormZi(fId)
+
   return (
     <div className={styles.Z0edit} id='editBox'>
       <div className='pageTitle'>
         资源{pageKey.txt}-{pageKeyTxt}&emsp;资源库:{kuTxt || '-'}
       </div>
-
       {info.id && kuTxt ? (
         <div className='editMain'>
           {/* ----------------审批-------------------- */}
@@ -389,12 +395,8 @@ function Z0edit({ pageKey, APIobj, topArr, selectTxt, selcctOne = false }: Props
             )}
           </div>
 
-          {/* <Table
-            columns={columns}
-            dataSource={dataSource}
-            scroll={{ x: 'max-content' }}
-            pagination={false}
-          /> */}
+          {/* 表格 */}
+          <Z0sonTable kuList={kuList} formZi={formZi} tableList={snaps} />
 
           {/* -------------底部按钮 */}
           <div className='EditBtn'>
@@ -461,20 +463,22 @@ function Z0edit({ pageKey, APIobj, topArr, selectTxt, selcctOne = false }: Props
             ) : null}
           </div>
         </div>
-      ) : (
-        <div hidden={!loding} className='Z0null'>
-          资源库数据异常 或 资源库状态被停用
-        </div>
-      )}
+      ) : null}
 
+      {info.id && loding && !kuTxt ? (
+        <div className='Z0null'>资源库数据异常 或 资源库状态被停用</div>
+      ) : null}
       {/* 选择资源 */}
       {openSelect ? (
         <SelectGoods
           API_getList={C1_APIgetGoodsList}
           closeFu={() => setOpenSelect(0)}
-          dataResFu={data => setInfo({ ...info, snaps: data })}
-          oldCheckArr={info.snaps}
+          dataResFu={data => setSnaps(data)}
+          oldCheckArr={snaps}
           formDefId={openSelect}
+          kuList={kuList}
+          formBi={formBi}
+          formZi={formZi}
           isOne={selcctOne}
         />
       ) : null}

+ 0 - 11
src/pages/Zother/Z0table/index.module.scss

@@ -14,17 +14,6 @@
           display: flex;
           align-items: center;
         }
-        .Z0ku {
-          .ant-select-selector {
-            background-color: var(--txtColor);
-            .ant-select-selection-item {
-              color: #fff;
-            }
-          }
-          .anticon-down {
-            color: #fff;
-          }
-        }
       }
     }
   }

+ 8 - 4
src/pages/Zother/Z0table/index.tsx

@@ -8,6 +8,7 @@ import { tableListAuditBtnFu } from '@/utils/authority'
 import { getKuListByOpenFu } from '../data'
 import { antdSelectType, selectObj } from '@/utils/dataChange'
 import MyTable from '@/components/MyTable'
+import { ziyuanAcGet, ziyuanAcSet } from '@/utils/storage'
 const { RangePicker } = DatePicker
 
 const baseForm = { pageNum: 1, pageSize: 10, formDefId: 0 }
@@ -35,7 +36,10 @@ function Z0table({ topSearchArr, getListAPI, pageKey, yHeight = 660, tableInfo }
       setLoding(true)
       if (data && data.length) {
         setKuList(data)
-        const obj = { ...baseForm, formDefId: data[0].value }
+
+        const ziyuanAcTxt = ziyuanAcGet()
+
+        const obj = { ...baseForm, formDefId: ziyuanAcTxt || data[0].value }
         setFormData(obj)
         dispatch(getListAPI(obj))
       }
@@ -197,14 +201,14 @@ function Z0table({ topSearchArr, getListAPI, pageKey, yHeight = 660, tableInfo }
               &emsp;
               <Button onClick={resetSelectFu}>重置</Button>
             </div>
-            <div>
+            <div className='Z0ku'>
               资源库:
               <Select
-                className='Z0ku'
-                style={{ maxWidth: 200 }}
+                style={{ maxWidth: 200, minWidth: 120 }}
                 value={formData.formDefId}
                 onChange={e => {
                   setFormData({ ...formData, pageNum: 1, formDefId: e })
+                  ziyuanAcSet(e)
                   setTimeout(() => {
                     setTimeKey(Date.now())
                   }, 50)

+ 4 - 5
src/pages/Zother/Z1formSet/index.tsx

@@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'
 import styles from './index.module.scss'
 import { Z1_APIformDel, Z1_APIformSort, Z1_APIgetInfo } from '@/store/action/Zsystem/Z1sysSet'
 import { Button, Cascader, Input, InputNumber, Select } from 'antd'
-import { baseFormFu, Z1tableType } from '@/pages/Zsystem/Z1sysSet/data'
+import { baseFormFu, formAddFilterFu, Z1tableType } from '@/pages/Zsystem/Z1sysSet/data'
 import { PlusOutlined, DeleteOutlined, CaretDownOutlined, CaretUpOutlined } from '@ant-design/icons'
 import MyPopconfirm from '@/components/MyPopconfirm'
 import { MessageFu } from '@/utils/message'
@@ -64,9 +64,7 @@ function Z1formSet({ sId, closeFu }: Props) {
   // 过滤3个状态
   const resList = useMemo(() => {
     const arr = info.fields || []
-    return arr.filter(
-      v => !['status_storage', 'status_publish', 'status_hot'].includes(v.fieldName)
-    )
+    return arr.filter(v => !formAddFilterFu().includes(v.fieldName))
   }, [info.fields])
 
   return (
@@ -95,7 +93,7 @@ function Z1formSet({ sId, closeFu }: Props) {
           {resList.map((item, index) => (
             <div className='formRow' key={item.id}>
               <div className='formLeft'>
-                {item.queryType === 1 ? <span>q </span> : null}
+                {[1, 2].includes(item.queryType) ? <span>q </span> : null}
                 {item.required === 1 ? <span>* </span> : null}
                 {item.fieldLabel}:
               </div>
@@ -135,6 +133,7 @@ function Z1formSet({ sId, closeFu }: Props) {
                   <Button type='primary'>关联资源</Button>
                 ) : ['关联字典', '关联标签'].includes(item.tag) ? (
                   <Cascader
+                    changeOnSelect
                     style={{ width: 500 }}
                     fieldNames={{ label: 'name', value: 'id', children: 'children' }}
                     options={treeOneIdByResFu(

+ 67 - 21
src/pages/Zother/Z2addForm/index.tsx

@@ -43,9 +43,14 @@ function Z2addForm({ sId, oldInfo, closeFu, upInfoFu }: Props) {
 
       fields.push({
         ...values,
-        dictId: tag === '关联字典' ? values.dictId1 : values.dictId2,
+        dictId:
+          tag === '关联字典'
+            ? Number(values.dictId1)
+            : tag === '关联标签'
+              ? Number(values.dictId2)
+              : null,
         isDict: ['关联字典', '关联标签'].includes(tag!) ? 1 : tag === '文本' ? 2 : 0,
-        fieldType: tag === '数字' ? 'number' : 'text',
+        fieldType: ['数字'].includes(tag!) ? 'number' : 'text',
         formDefId: sId,
         options: '',
         queryType,
@@ -85,6 +90,16 @@ function Z2addForm({ sId, oldInfo, closeFu, upInfoFu }: Props) {
         fieldName: 'file_ids',
         fieldLabel: '附件'
       })
+    } else if (tag === '关联资源') {
+      FormBoxRef.current?.setFieldsValue({
+        fieldName: 'form_ids',
+        fieldLabel: '关联资源'
+      })
+    } else {
+      FormBoxRef.current?.setFieldsValue({
+        fieldName: '',
+        fieldLabel: ''
+      })
     }
   }, [tag])
 
@@ -93,25 +108,46 @@ function Z2addForm({ sId, oldInfo, closeFu, upInfoFu }: Props) {
 
   const dictArr = useMemo(() => {
     let arr: any[] = []
-    if (dictArrTemp && dictArrTemp.length)
-      arr = dictArrTemp.map(v => ({ value: v.id, label: v.name }))
+    if (dictArrTemp && dictArrTemp.length) {
+      const dictIdArr = (oldInfo.fields || []).filter(c => c.dictId).map(v => v.dictId + '')
+      arr = dictArrTemp.map(v => ({
+        value: v.id,
+        label: v.name,
+        disabled: dictIdArr.includes(v.id)
+      }))
+    }
     return arr
-  }, [dictArrTemp])
+  }, [dictArrTemp, oldInfo.fields])
 
   // 关联标签
   const biaoQianTemp = useSelector((state: RootState) => state.B3resTag.dictAll)
 
   const biaoQian = useMemo(() => {
     let arr: any[] = []
-    if (biaoQianTemp && biaoQianTemp.length)
-      arr = biaoQianTemp.map(v => ({ value: v.id, label: v.name }))
+    if (biaoQianTemp && biaoQianTemp.length) {
+      const dictIdArr = (oldInfo.fields || []).filter(c => c.dictId).map(v => v.dictId + '')
+
+      arr = biaoQianTemp.map(v => ({
+        value: v.id,
+        label: v.name,
+        disabled: dictIdArr.includes(v.id)
+      }))
+    }
     return arr
-  }, [biaoQianTemp])
+  }, [biaoQianTemp, oldInfo.fields])
 
   const tagArr = useMemo(() => {
+    const arr: string[] = []
+    let oldArr = selectObj['表单字段类型']
     const obj = oldInfo.fields.find(v => v.tag === '附件')
-    if (obj) return selectObj['表单字段类型'].filter(v => v.label !== '附件')
-    else return selectObj['表单字段类型']
+    if (obj) arr.push('附件')
+
+    const obj2 = oldInfo.fields.find(v => v.tag === '关联资源')
+    if (obj2) arr.push('关联资源')
+
+    oldArr = oldArr.filter(v => !arr.includes(v.label))
+
+    return oldArr
   }, [oldInfo.fields])
 
   return (
@@ -133,6 +169,16 @@ function Z2addForm({ sId, oldInfo, closeFu, upInfoFu }: Props) {
         autoComplete='off'
         // initialValues={{ sort: 999 }}
       >
+        <Form.Item label='字段类型' name='tag' rules={[{ required: true, message: '请选择' }]}>
+          <Select
+            value={tag}
+            onChange={e => setTag(e)}
+            options={tagArr}
+            style={{ width: 300 }}
+            placeholder='请选择'
+          />
+        </Form.Item>
+
         <Form.Item
           label='字段名(英文)'
           name='fieldName'
@@ -142,7 +188,12 @@ function Z2addForm({ sId, oldInfo, closeFu, upInfoFu }: Props) {
           ]}
           getValueFromEvent={e => e.target.value.replace(/\s+/g, '').toLowerCase()}
         >
-          <Input disabled={tag === '附件'} maxLength={20} showCount placeholder='请输入' />
+          <Input
+            disabled={['附件', '关联资源'].includes(tag!) || !tag}
+            maxLength={20}
+            showCount
+            placeholder={tag ? '请输入' : '请先选择字段类型'}
+          />
         </Form.Item>
 
         <Form.Item
@@ -151,16 +202,11 @@ function Z2addForm({ sId, oldInfo, closeFu, upInfoFu }: Props) {
           rules={[{ required: true, message: '请输入' }]}
           getValueFromEvent={e => e.target.value.trim()}
         >
-          <Input disabled={tag === '附件'} maxLength={10} showCount placeholder='请输入' />
-        </Form.Item>
-
-        <Form.Item label='字段类型' name='tag' rules={[{ required: true, message: '请选择' }]}>
-          <Select
-            value={tag}
-            onChange={e => setTag(e)}
-            options={tagArr}
-            style={{ width: 300 }}
-            placeholder='请选择'
+          <Input
+            disabled={['附件', '关联资源'].includes(tag!) || !tag}
+            maxLength={10}
+            showCount
+            placeholder={tag ? '请输入' : '请先选择字段类型'}
           />
         </Form.Item>
 

+ 0 - 16
src/pages/Zother/data.tsx

@@ -103,19 +103,3 @@ export type TypetableAuditList = {
   type?: any
   updateTime: string
 }
-
-// 动态表单展示
-export const tableColumns = () => {
-  const arr1: any[] = [
-    {
-      title: 'Full Name',
-      width: 100,
-      dataIndex: 'name',
-      fixed: 'start'
-    }
-  ]
-  const arr2: any[] = []
-  const arr3: any[] = []
-
-  return [...arr1, ...arr2, ...arr3]
-}

+ 53 - 19
src/pages/Zsystem/Z1sysSet/data.ts

@@ -48,6 +48,19 @@ export const baseFormFu = (id?: any) => {
     },
     {
       dictId: '',
+      fieldLabel: '资源编码',
+      fieldName: 'num',
+      fieldType: 'text',
+      formDefId: id,
+      isDict: 0,
+      options: '',
+      queryType: 2,
+      required: 1,
+      sort: 2,
+      tag: '文本'
+    },
+    {
+      dictId: '',
       fieldLabel: '责任者',
       fieldName: 'create_by',
       fieldType: 'text',
@@ -56,7 +69,7 @@ export const baseFormFu = (id?: any) => {
       options: '',
       queryType: 2,
       required: 1,
-      sort: 1,
+      sort: 3,
       tag: '文本'
     },
     {
@@ -69,35 +82,36 @@ export const baseFormFu = (id?: any) => {
       options: '',
       queryType: 0,
       required: 1,
-      sort: 1,
+      sort: 4,
       tag: '封面'
     },
     {
       dictId: '',
-      fieldLabel: '权限级',
-      fieldName: 'level_perm',
-      fieldType: 'select',
+      fieldLabel: '大封面',
+      fieldName: 'thumbPc',
+      fieldType: 'text',
       formDefId: id,
       isDict: 0,
-      options: selectObj['权限级'].map(v => v.label).join(','),
-      queryType: 1,
+      options: '',
+      queryType: 0,
       required: 1,
-      sort: 1,
-      tag: '下拉'
+      sort: 5,
+      tag: '大封面'
     },
     {
       dictId: '',
-      fieldLabel: '排序值',
-      fieldName: 'sort',
-      fieldType: 'number',
+      fieldLabel: '权限级',
+      fieldName: 'level_perm',
+      fieldType: 'select',
       formDefId: id,
       isDict: 0,
-      options: '',
-      queryType: 0,
+      options: selectObj['权限级'].map(v => v.label).join(','),
+      queryType: 1,
       required: 1,
-      sort: 1,
-      tag: '数字'
+      sort: 6,
+      tag: '下拉'
     },
+
     {
       dictId: '',
       fieldLabel: '入库状态',
@@ -108,7 +122,7 @@ export const baseFormFu = (id?: any) => {
       options: '',
       queryType: 1,
       required: 0,
-      sort: 1,
+      sort: 7,
       tag: '数字'
     },
     {
@@ -121,7 +135,7 @@ export const baseFormFu = (id?: any) => {
       options: '',
       queryType: 1,
       required: 0,
-      sort: 1,
+      sort: 8,
       tag: '数字'
     },
     {
@@ -134,10 +148,30 @@ export const baseFormFu = (id?: any) => {
       options: '',
       queryType: 1,
       required: 0,
-      sort: 1,
+      sort: 9,
+      tag: '数字'
+    },
+
+    {
+      dictId: '',
+      fieldLabel: '排序值',
+      fieldName: 'sort',
+      fieldType: 'number',
+      formDefId: id,
+      isDict: 0,
+      options: '',
+      queryType: 0,
+      required: 1,
+      sort: 10,
       tag: '数字'
     }
   ]
 
   return arr
 }
+
+// 在表单设计页面需要过滤的
+export const formAddFilterFu = (other: any[] = []) => {
+  const arr = ['status_storage', 'status_publish', 'status_hot', 'thumbPc']
+  return [...arr, ...other]
+}

+ 1 - 1
src/pages/Zsystem/Z6roleSet/Z6edit.tsx

@@ -7,7 +7,7 @@ import classNmaes from 'classnames'
 import { MessageFu } from '@/utils/message'
 import { TypeZ6Role } from './data'
 import { Z6_APIgetAddTreeList, Z6_APIgetInfo, Z6_APIsave } from '@/store/action/Zsystem/Z6roleSet'
-import { useKuList } from '@/pages/Zother/UseKuList'
+import { useKuList } from '@/pages/Zuse/UseKuList'
 
 type Props = {
   sId: number

+ 42 - 0
src/pages/Zuse/UseFormZi.tsx

@@ -0,0 +1,42 @@
+import { useCallback, useEffect, useState } from 'react'
+
+import { baseFormType } from '../Zsystem/Z1sysSet/data'
+import { Z1_APIgetFormZiDuan } from '@/store/action/Zsystem/Z1sysSet'
+
+// 需要过滤的字段
+const baseFilter = [
+  'name',
+  'create_by',
+  'thumb',
+  'sort',
+  'status_storage',
+  'status_publish',
+  'status_hot'
+]
+
+export function UseFormZi(id: number, filterArr?: string[]) {
+  // 获取表单字段
+  const [formZi, setFormZi] = useState<baseFormType[]>([])
+
+  // 可搜索字段
+  const [formBi, setFormBi] = useState<baseFormType[]>([])
+
+  const getListFu = useCallback(async () => {
+    const res = await Z1_APIgetFormZiDuan(id)
+    if (res.code === 0) {
+      const list: any[] = res.data || {}
+      setFormZi(list)
+      setFormBi(
+        list.filter(
+          v => v.queryType && ![...baseFilter, ...(filterArr || [])].includes(v.fieldName)
+        )
+      )
+    }
+  }, [filterArr, id])
+
+  useEffect(() => {
+    getListFu()
+  }, [getListFu])
+
+  return { formZi, formBi }
+}

src/pages/Zother/UseKuList.tsx → src/pages/Zuse/UseKuList.tsx


+ 5 - 0
src/store/action/Zsystem/Z1sysSet.ts

@@ -75,3 +75,8 @@ export const Z1_APIformDel = (id: number) => {
 export const Z1_APIformSort = (id1: number, id2: number) => {
   return http.get(`cms/form/field/sort/${id1}/${id2}`)
 }
+
+// -----------------获取表单字段-------------------
+export const Z1_APIgetFormZiDuan = (id: number) => {
+  return http.get(`cms/form/field/list/${id}`)
+}

+ 38 - 0
src/utils/index.ts

@@ -1,3 +1,4 @@
+import store from '@/store'
 import { baseURL } from './http'
 
 // 上传文件自动归类
@@ -63,3 +64,40 @@ export const downloadFileByUrl = async (fileUrl: string, fileName?: string, back
   document.body.removeChild(a)
   if (back) back()
 }
+
+// 字典、标签 回显数据 - 通过爷id,父id,自己id
+// 返回格式:爷文本 / 父文本 / 自己文本
+// 如果没有找到数据返回(空)
+export const dictIdByName = (ids: string): string => {
+  if (!ids) return '(空)'
+
+  const idArr = ids.split(',').filter(Boolean)
+  if (!idArr.length) return '(空)'
+
+  const arr1 = store.getState().B3resTag.dictAll
+  const arr2 = store.getState().Z2dict.dictAll
+  const arr = [...arr1, ...arr2]
+
+  // 性能优化:构建 Map 缓存,O(1) 查找
+  const nodeMap = new Map<string, (typeof arr)[0]>()
+  const flattenTree = (nodes: typeof arr) => {
+    for (const node of nodes) {
+      nodeMap.set(node.id, node)
+      if (node.children?.length) {
+        flattenTree(node.children)
+      }
+    }
+  }
+  flattenTree(arr)
+
+  // 按传入的id顺序查找对应的name
+  const names: string[] = []
+  for (const id of idArr) {
+    const node = nodeMap.get(String(id))
+    if (node?.name) {
+      names.push(node.name)
+    }
+  }
+
+  return names && names.length ? names.join(' / ') : '(空)'
+}

+ 5 - 29
src/utils/storage.ts

@@ -1,6 +1,6 @@
 // ------------------------------------token的本地存储------------------------------------
 // 用户 Token 的本地缓存键名,自己定义
-const TOKEN_KEY = 'QING_DAO_PI_JIU_GOODS_HOUTAI_USETINFO'
+const TOKEN_KEY = 'HAN_SHAN_SHI_FAN_GOODS_HOUTAI_USETINFO'
 
 /**
  * 从本地缓存中获取 用户 信息
@@ -38,40 +38,16 @@ export const getTokenFu = (): string => {
   return getTokenInfo().token
 }
 
-// // --------------------工作台-常用功能存储
-// const CHANG_KEY = 'QING_DAO_PI_JIU_GOODS_HT_CHANG_ARR'
-
-// // 存
-// export const changSetFu = (info: RouterTypeRow): void => {
-//   const oldArr = changGetFu()
-
-//   let newArr: RouterTypeRow[] = []
-
-//   // 已经存在了
-//   const oldIds = oldArr.map(v => v.id)
-//   if (oldIds.includes(info.id)) newArr = oldArr
-//   else {
-//     if (oldArr.length <= 2) newArr = [...oldArr, info]
-//     else newArr = [...oldArr.slice(-2), info]
-//   }
-
-//   localStorage.setItem(CHANG_KEY, JSON.stringify(newArr))
-// }
-// // 取
-// export const changGetFu = (): RouterTypeRow[] => {
-//   return JSON.parse(localStorage.getItem(CHANG_KEY) || '[]')
-// }
-
-// ------------------藏品详情id,回跳需要
-const GOODPAGE_KEY = 'QING_DAO_PI_JIU_GOODPAGE_KEY'
+// ------------------当前选中的资源库--获取外层列表信息
+const GOODPAGE_KEY = 'HAN_SHAN_SHI_FAN_ZIYUAN_AC'
 
 // 存
-export const infoPageIDSet = (id: number) => {
+export const ziyuanAcSet = (id: number) => {
   localStorage.setItem(GOODPAGE_KEY, id + '')
 }
 
 // 取
-export const infoPageIDGet = () => {
+export const ziyuanAcGet = () => {
   let res = 0
   let txt = localStorage.getItem(GOODPAGE_KEY) || ''
   if (txt) res = Number(txt)