|
@@ -1,10 +1,9 @@
|
|
|
import DatePicker from '@/components/DatePicker'
|
|
|
import { tenderStore } from '@/store/mobx'
|
|
|
-import consts from '@/utils/consts'
|
|
|
+import { handleAutoCode } from '@/utils/util'
|
|
|
import { Form, Input, Modal } from 'antd'
|
|
|
import locale from 'antd/es/date-picker/locale/zh_CN'
|
|
|
import React, { useEffect } from 'react'
|
|
|
-import { apiAutoCode } from './api'
|
|
|
import styles from './index.module.scss'
|
|
|
interface iSafeCreateFormProps {
|
|
|
visible: boolean;
|
|
@@ -20,24 +19,11 @@ const SafeCreateForm: React.FC<iSafeCreateFormProps> = ({
|
|
|
onCancel
|
|
|
}) => {
|
|
|
const [ form ] = Form.useForm()
|
|
|
- const autoCodeHandler = async () => {
|
|
|
- const { code = -1, data = "" } = await apiAutoCode(tenderStore.tender.bidsectionId, 'safeRule')
|
|
|
- if (code === consts.RET_CODE.SUCCESS) {
|
|
|
- if (data) {
|
|
|
- const ruleArr: string[] = []
|
|
|
- const code = JSON.parse(data)
|
|
|
- for (const key in code) {
|
|
|
- if (Object.prototype.hasOwnProperty.call(code, key)) {
|
|
|
- const element = code[key]
|
|
|
- if (element) {
|
|
|
- ruleArr.push(element)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- form.setFieldsValue({ code: ruleArr.join("-") })
|
|
|
- }
|
|
|
- }
|
|
|
+ const autoCode = async () => {
|
|
|
+ const ruleArr = await handleAutoCode(tenderStore.tender.bidsectionId, 'safeRule')
|
|
|
+ form.setFieldsValue({ code: ruleArr.join('-') })
|
|
|
}
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
if (visible) {
|
|
|
form.setFieldsValue({ bidsectionId: tenderStore.tender.bidsectionId })
|
|
@@ -77,7 +63,7 @@ const SafeCreateForm: React.FC<iSafeCreateFormProps> = ({
|
|
|
<Input />
|
|
|
</Form.Item>
|
|
|
<Form.Item name="code" label="安全编号" rules={[ { required: true, message: '请输入/生成安全编号' } ]}>
|
|
|
- <Input addonAfter={<span className="pi-pd-lr-11"onClick={() => autoCodeHandler()}>自动编号</span>}/>
|
|
|
+ <Input addonAfter={<span className="pi-pd-lr-11"onClick={() => autoCode()}>自动编号</span>}/>
|
|
|
</Form.Item>
|
|
|
<Form.Item name="inspection" label="检查项" rules={[ { required: true, message: '请填写检查项' } ]}>
|
|
|
<Input placeholder="请填写巡检项"/>
|