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. 55
      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[];

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

@ -34,7 +34,7 @@ const ProjectAddModel = ({ dispatch, actions, user, modelData, close, success, q
map: map
}); //构造地点查询类
function select (e) {
function select(e) {
if (e) {
placeSearch.setCity(e.poi.adcode);
placeSearch.search(e.poi.name, function (status, result) {
@ -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}
@ -91,38 +101,40 @@ const ProjectAddModel = ({ dispatch, actions, user, modelData, close, success, q
>
<Input placeholder="请输入点位名称" allowClear />
</Form.Item>
<div style={{position: 'relative'}}>
<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: '', },{
<Form.Item label="所在地区:" labelCol={{ span: 11 }} labelAlign='right' name="longitude" style={{ display: 'inline-block', width: 'calc(60% - 30px)', }}
rules={[{ required: false, message: '', }, {
validator: (rule, value, callback) => {
const sjh = /^\d+$|^\d*\.\d+$/g;
if (value) {
if (value) {
let valid = sjh.test(value);
if (!valid) {
return callback([new Error("横坐标填写错误")]);
}
callback();
}
return callback([new Error("请输入横坐标")]);
// return callback([new Error("请输入横坐标")]);
return Promise.resolve();
}
}]}
>
<Input placeholder="经度支持数字" />
</Form.Item>
~
<Form.Item name="latitude" style={{ display: 'inline-block', width: 'calc(40% + 15px)', }}
rules={[{ required: true, message: '', },{
<Form.Item name="latitude" style={{ display: 'inline-block', width: 'calc(40% + 15px)', }}
rules={[{ required: false, message: '', }, {
validator: (rule, value, callback) => {
const sjh = /^\d+$|^\d*\.\d+$/g;
if (value) {
if (value) {
let valid = sjh.test(value);
if (!valid) {
return callback([new Error("纵坐标填写错误")]);
}
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>
@ -159,7 +190,7 @@ const ProjectAddModel = ({ dispatch, actions, user, modelData, close, success, q
};
function mapStateToProps (state) {
function mapStateToProps(state) {
const { auth, global } = state;
return {
user: auth.user,

Loading…
Cancel
Save