Yansen hace 2 años
padre
commit
0134debb56

+ 5
- 3
src/pages/guaranteeTask/Edit/DishList.jsx Ver fichero

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

+ 10
- 3
src/pages/guaranteeTask/Edit/components/Selector.jsx Ver fichero

@@ -5,7 +5,7 @@ const { Group } = Input;
5 5
 const { Option } = Select;
6 6
 
7 7
 export default (props) => {
8
-  const { fetch, placeholder, onSubmit } = props;
8
+  const { fetch, placeholder, disabled, onSubmit } = props;
9 9
 
10 10
   const [data, setData] = useState([]);
11 11
   const [value, setValue] = useState();
@@ -51,6 +51,7 @@ export default (props) => {
51 51
       <Select
52 52
         allowClear
53 53
         showSearch
54
+        disabled={disabled}
54 55
         value={value}
55 56
         style={{ width: '50%' }}
56 57
         placeholder={placeholder}
@@ -63,8 +64,14 @@ export default (props) => {
63 64
       >
64 65
         {options}
65 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 75
     </Group>
69 76
   )
70 77
 }