Ubuntu преди 1 седмица
родител
ревизия
0baf89b73d
променени са 4 файла, в които са добавени 66 реда и са изтрити 11 реда
  1. 1 1
      src/Bjhz.js
  2. 36 10
      src/Home2.js
  3. 8 0
      src/Service.js
  4. 21 0
      src/SimpleService.js

+ 1 - 1
src/Bjhz.js

@@ -11,7 +11,7 @@ export default function Bjhz({data}) {
     React.useEffect(() => {
       myTable.current = new Tabulator(myRef.current, {
            index: "key",
-           height: 650,
+           height: 670,
          data: data, //link data to table
          reactiveData: false, //enable data reactivity
          dataTreeStartExpanded:true,

+ 36 - 10
src/Home2.js

@@ -49,6 +49,7 @@ export default function Home2() {
   const drawerWidth = 240;
   const theme = useTheme();
   const scrollRef = React.useRef(null);
+  const huizongRef = React.useRef(null);
   const tableRef = React.useRef(null);
   const deleteItem = React.useCallback(
     (id, navigate) => () => {
@@ -287,7 +288,7 @@ export default function Home2() {
                 link.href = url;
     
                  // Set the link attributes for downloading
-                link.setAttribute('download', value.concat('.xml'));
+                link.setAttribute('download', value.concat('.13jt'));
     
                  // Programmatically click the link to initiate the download
                 link.click();
@@ -295,7 +296,10 @@ export default function Home2() {
                  // Clean up the temporary URL
                 URL.revokeObjectURL(url);
                 setBopen(false);
-             })
+                setTimeout(function() {
+                  scrollRef.current = null;
+                 }, 1000);
+                 })
              .catch(error => console.error(error));
           }}
         >
@@ -335,10 +339,11 @@ export default function Home2() {
             console.log(value);
             event.stopPropagation();
             scrollRef.current = apiRef.current.getScrollPosition();
-            setBopen(true);
-            SimpleService.hebing(value).then(x=>{
-                 navigate('/editor/qingdan/'.concat(x));
-	    });
+            setDopen4(true);
+            huizongRef.current = value;
+           // SimpleService.hebing(value).then(x=>{
+           //      navigate('/editor/qingdan/'.concat(x));
+	   // });
           }}
         >
           合并清单
@@ -476,6 +481,11 @@ export default function Home2() {
          pageSize: 100,
          page: 0,
      });
+    const [sortModel, setSortModel] = React.useState([{
+         field: '创建时间',
+         sort: 'desc',
+     }]);
+
     const handleFileChange = (event) => {
          console.log(event.target.files);
          const fd = new FormData();
@@ -642,6 +652,20 @@ const handleClose4 = () => {
         scrollRef.current = null;
     }, 1000);
   };
+  const handleOpenHuizong = () => {
+	    setBopen(true);
+	    handleClose6();
+            SimpleService.hebing(huizongRef.current).then(x=>{
+                 navigate('/editor/qingdan/'.concat(x));
+	    });
+  };
+  const handleRefreshHuizong = () => {
+	    setBopen(true);
+	    handleClose6();
+            SimpleService.refresh(huizongRef.current).then(x=>{
+                 navigate('/editor/qingdan/'.concat(huizongRef.current));
+	    });
+  };
 
   const handleDelete = () => {
     setTimeout(function() {
@@ -780,6 +804,8 @@ const handleClose4 = () => {
       disableColumnMenu={true}
 	    paginationModel={paginationModel}
             onPaginationModelChange={setPaginationModel}
+            sortModel={sortModel}
+            onSortModelChange={(newSortModel) => setSortModel(newSortModel)}
       localeText={zhCN.components.MuiDataGrid.defaultProps.localeText}
       />
 
@@ -803,10 +829,10 @@ const handleClose4 = () => {
         aria-describedby="alert-dialog-description"
       >
         
-        <DialogActions>
-          <Button onClick={handleClose6}>打开汇总清单</Button>
-          <Button onClick={handleClose6}>
-            更新始清单
+        <DialogActions sx={{p: 4}}>
+          <Button variant="outlined" size="large" onClick={handleOpenHuizong}>打开合并清单</Button>
+          <Button variant="outlined" size="large" sx={{ml: 2}}  onClick={handleRefreshHuizong}>
+            更新始清单
           </Button>
         </DialogActions>
       </Dialog>

+ 8 - 0
src/Service.js

@@ -2577,11 +2577,13 @@ class Service{
     handleAI_djcs(result) {
         let keys = Object.keys(result);
         let datakey = null;
+	let changed = false;
         for (let i = 0; i < keys.length; i++) {
             let key = keys[i]
             let hits = this.cache_djcs.filter(x=>x['清单编码']==key);
             let qd = hits[0]
 	    if (qd == null)continue;
+	    changed = true;
             let r = result[key]
             let rr = r['result']
             let rrr = rr['result'][0]
@@ -2603,10 +2605,16 @@ class Service{
             qd['辅材费'] = String(rrr['辅材费'])
             qd['_children'] = rrr['_children']
         }
+	    if (changed){
                 this.push_op_djcs(copy(this.cache_djcs));
             
+                this.updateFootprint_djcs(datakey);
 
                 return [true, copy(this.cache_djcs), datakey];
+	    } else {
+                return [false, null, null];
+
+	    }
     }
 
     handleAI(result) {

+ 21 - 0
src/SimpleService.js

@@ -798,6 +798,27 @@ async generateQingdanTuijian(name, bh, bt, bm) {
             return data;
         }
     }
+    async refresh(id) {
+        const response = await fetch(this.ip().concat( "/refresh/"), {
+            method : "POST",
+            headers: {
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
+            },
+            body: JSON.stringify(
+                {
+                    "name": id
+                }
+            )
+        });
+        if (!response.ok) {
+            //const error = await response.json();
+            console.error('error');
+        } else {
+            const data = await response.json();
+            return data;
+        }
+    }
 
     async applyFL(id, data) {
         const response = await fetch(this.ip().concat( "/applyFL/"), {