Yansen 2 years ago
parent
commit
0134debb56

+ 5
- 3
src/pages/guaranteeTask/Edit/DishList.jsx View File

99
   }
99
   }
100
 
100
 
101
   useEffect(() => {
101
   useEffect(() => {
102
-    if (dataSource.id) {
102
+    if (dataSource && dataSource.id) {
103
       setLoading(true);
103
       setLoading(true);
104
       getGuaranteeDetailList({ pageNum: 1, pageSize: 500, guaranteeId: dataSource.id }).then(res => {
104
       getGuaranteeDetailList({ pageNum: 1, pageSize: 500, guaranteeId: dataSource.id }).then(res => {
105
         setLoading(false);
105
         setLoading(false);
108
         setLoading(false);
108
         setLoading(false);
109
       })
109
       })
110
     }
110
     }
111
-  }, [dataSource.id])
111
+  }, [dataSource])
112
 
112
 
113
   return (
113
   return (
114
     <Row gutter={48}>
114
     <Row gutter={48}>
117
           <h3>选择套餐</h3>
117
           <h3>选择套餐</h3>
118
           <Selector
118
           <Selector
119
             placeholder="请选择套餐"
119
             placeholder="请选择套餐"
120
+            disabled={!dataSource}
120
             fetch={getPackageList}
121
             fetch={getPackageList}
121
             onSubmit={handlePackageSubmit}
122
             onSubmit={handlePackageSubmit}
122
           />
123
           />
125
           <h3>选择菜肴</h3>
126
           <h3>选择菜肴</h3>
126
           <Selector
127
           <Selector
127
             placeholder="请选择菜肴"
128
             placeholder="请选择菜肴"
129
+            disabled={!dataSource}
128
             fetch={getDishList}
130
             fetch={getDishList}
129
             onSubmit={handleDishSubmit}
131
             onSubmit={handleDishSubmit}
130
           />
132
           />
134
         <Card
136
         <Card
135
           title="已选菜肴"
137
           title="已选菜肴"
136
           loading={loading}
138
           loading={loading}
137
-          extra={<Button type='primary' loading={loading} onClick={onSubmit}>保存</Button>}
139
+          extra={<Button disabled={!dataSource} type='primary' loading={loading} onClick={onSubmit}>保存</Button>}
138
         >
140
         >
139
           <EditableTag
141
           <EditableTag
140
             list={list}
142
             list={list}

+ 10
- 3
src/pages/guaranteeTask/Edit/components/Selector.jsx View File

5
 const { Option } = Select;
5
 const { Option } = Select;
6
 
6
 
7
 export default (props) => {
7
 export default (props) => {
8
-  const { fetch, placeholder, onSubmit } = props;
8
+  const { fetch, placeholder, disabled, onSubmit } = props;
9
 
9
 
10
   const [data, setData] = useState([]);
10
   const [data, setData] = useState([]);
11
   const [value, setValue] = useState();
11
   const [value, setValue] = useState();
51
       <Select
51
       <Select
52
         allowClear
52
         allowClear
53
         showSearch
53
         showSearch
54
+        disabled={disabled}
54
         value={value}
55
         value={value}
55
         style={{ width: '50%' }}
56
         style={{ width: '50%' }}
56
         placeholder={placeholder}
57
         placeholder={placeholder}
63
       >
64
       >
64
         {options}
65
         {options}
65
       </Select>
66
       </Select>
66
-      <InputNumber style={{ width: '30%' }} placeholder="请输入数量" value={amount} onChange={setAmount} />
67
-      <Button type="primary" onClick={handleSubmit}>确定</Button>
67
+      <InputNumber
68
+        style={{ width: '30%' }}
69
+        placeholder="请输入数量"
70
+        disabled={disabled}
71
+        value={amount}
72
+        onChange={setAmount}
73
+      />
74
+      <Button type="primary" disabled={disabled} onClick={handleSubmit}>确定</Button>
68
     </Group>
75
     </Group>
69
   )
76
   )
70
 }
77
 }