Browse Source

点位经纬度设为非必填,增加图片上传

master
liujiangyong 2 years ago
parent
commit
0b10214468
  1. 4
      api/app/lib/controllers/projectRegime/projectSituation.js
  2. 9
      api/app/lib/models/point.js
  3. 2
      script/1.0.3/schema/4.update_point.sql
  4. 41
      web/client/src/sections/projectRegime/components/pointModel.js

4
api/app/lib/controllers/projectRegime/projectSituation.js

@ -164,10 +164,10 @@ async function addPosition(ctx, next) {
const models = ctx.fs.dc.models;
let userInfo = ctx.fs.api.userInfo;
const data = ctx.request.body;
const { longitude, latitude, name, describe, qrCode, projectId, } = data;
const { longitude, latitude, name, describe, qrCode, projectId, img } = data;
let errMsg = data.id ? '点位编辑失败' : '点位新增失败'
let pointData = { longitude, latitude, name, describe, qrCode, projectId }
let pointData = { longitude, latitude, name, describe, qrCode, projectId, img }
const alikeProject = await models.Point.findOne({
where: {

9
api/app/lib/models/point.js

@ -69,6 +69,15 @@ module.exports = dc => {
field: "qr_code",
autoIncrement: false
},
img: {
type: DataTypes.ARRAY(DataTypes.STRING),
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: false,
field: "img",
autoIncrement: false
},
}, {
tableName: "point",
comment: "",

2
script/1.0.3/schema/4.update_point.sql

@ -0,0 +1,2 @@
ALTER TABLE "public"."point"
ADD COLUMN "img" character varying[];

41
web/client/src/sections/projectRegime/components/pointModel.js

@ -64,7 +64,10 @@ const ProjectAddModel = ({ dispatch, actions, user, modelData, close, success, q
dispatch(projectRegime.addPosition({
...r,
id: modelData?.id,
projectId: qrCodeId
projectId: qrCodeId,
latitude: r?.latitude ? r?.latitude : null,
longitude: r?.longitude ? r?.longitude : null,
img: r.img ? r.img.map(u => u.storageUrl) : [],
})).then(res => {
if (res.success) {
success()
@ -84,6 +87,13 @@ const ProjectAddModel = ({ dispatch, actions, user, modelData, close, success, q
onFinish={r => {
}}
initialValues={{
img: (modelData.img || []).map(s => {
return {
storageUrl: s
}
}),
}}
>
<Form.Item label='点位名称' name="name" style={{}}
initialValue={modelData?.name}
@ -94,7 +104,7 @@ const ProjectAddModel = ({ dispatch, actions, user, modelData, close, success, q
<div style={{ position: 'relative' }}>
{/* /^\d+$|^\d*\.\d+$/g */}
<Form.Item label="所在地区:" labelCol={{ span: 11 }} labelAlign='right' name="longitude" style={{ display: 'inline-block', width: 'calc(60% - 30px)', }}
rules={[{ required: true, message: '', },{
rules={[{ required: false, message: '', }, {
validator: (rule, value, callback) => {
const sjh = /^\d+$|^\d*\.\d+$/g;
if (value) {
@ -104,7 +114,8 @@ const ProjectAddModel = ({ dispatch, actions, user, modelData, close, success, q
}
callback();
}
return callback([new Error("请输入横坐标")]);
// return callback([new Error("请输入横坐标")]);
return Promise.resolve();
}
}]}
>
@ -112,7 +123,7 @@ const ProjectAddModel = ({ dispatch, actions, user, modelData, close, success, q
</Form.Item>
~
<Form.Item name="latitude" style={{ display: 'inline-block', width: 'calc(40% + 15px)', }}
rules={[{ required: true, message: '', },{
rules={[{ required: false, message: '', }, {
validator: (rule, value, callback) => {
const sjh = /^\d+$|^\d*\.\d+$/g;
if (value) {
@ -122,7 +133,8 @@ const ProjectAddModel = ({ dispatch, actions, user, modelData, close, success, q
}
callback();
}
return callback([new Error("请输入纵坐标")]);
// return callback([new Error("请输入纵坐标")]);
return Promise.resolve();
}
}]}
>
@ -152,6 +164,25 @@ const ProjectAddModel = ({ dispatch, actions, user, modelData, close, success, q
rules={[{ required: true, message: '请输入描述内容', },]}>
<TextArea />
</Form.Item>
<Form.Item
label="结构物图片"
name='img'
help={<div style={{ fontSize: 12 }}>说明请上传pngjpg格式图片图片大小不超过5M</div>}
>
<Uploads
listType='picture-card'
uploadType='project'
maxFilesNum={1}
maxFileSize={5}
isQiniu={true}
fileTypes={["png", "jpg"]}
defaultValue={(modelData.img || []).map(s => {
return {
storageUrl: s
}
})}
/>
</Form.Item>
</Form>
</Modal>

Loading…
Cancel
Save