|
@@ -1,403 +1,342 @@
|
|
|
<template>
|
|
|
- <van-nav-bar
|
|
|
- fixed
|
|
|
- title="消防设备添加"
|
|
|
- left-text=""
|
|
|
- left-arrow
|
|
|
- @click-left="onClickLeft"
|
|
|
- :style="{ 'background-color': selectColor }"
|
|
|
- >
|
|
|
- </van-nav-bar>
|
|
|
- <div class="main">
|
|
|
- <van-form @submit="submit" show-error :show-error-message="false">
|
|
|
- <van-cell-group>
|
|
|
- <van-field
|
|
|
- v-model="inputForm.name"
|
|
|
- center
|
|
|
- required
|
|
|
- :rules="[{ required: true }]"
|
|
|
- label="设备名称:"
|
|
|
- placeholder="请填写设备名称"
|
|
|
- input-align="right"
|
|
|
- />
|
|
|
- </van-cell-group>
|
|
|
- <van-cell-group>
|
|
|
- <van-field
|
|
|
- v-model="locationName"
|
|
|
- readonly
|
|
|
- required
|
|
|
- :rules="[{ required: true }]"
|
|
|
- label="所属场所:"
|
|
|
- placeholder="请选择所属场所"
|
|
|
- input-align="right"
|
|
|
- right-icon="arrow-down"
|
|
|
- @click="hs_site = true"
|
|
|
- >
|
|
|
- </van-field>
|
|
|
- <van-dialog v-model:show="hs_site" title="所属场所" show-cancel-button>
|
|
|
- <div class="dialog">
|
|
|
- <van-list
|
|
|
- v-model:loading="loading"
|
|
|
- :finished="finished"
|
|
|
- finished-text="没有更多了"
|
|
|
- @load="onLoad"
|
|
|
- >
|
|
|
- <van-radio-group v-model="checked">
|
|
|
- <van-cell-group inset>
|
|
|
- <van-cell
|
|
|
- v-for="item in sitelist"
|
|
|
- :key="item"
|
|
|
- :title="item.name"
|
|
|
- clickable
|
|
|
- @click="getsite(item)"
|
|
|
- >
|
|
|
- <template #right-icon>
|
|
|
- <van-radio :name="item.id" @click="getsite(item)" />
|
|
|
- </template>
|
|
|
- </van-cell>
|
|
|
- </van-cell-group>
|
|
|
- </van-radio-group>
|
|
|
- </van-list>
|
|
|
- </div>
|
|
|
- </van-dialog>
|
|
|
- </van-cell-group>
|
|
|
- <van-cell-group>
|
|
|
- <van-field
|
|
|
- v-model="inputForm.personInCharge"
|
|
|
- center
|
|
|
- required
|
|
|
- label-width="7.2em"
|
|
|
- :rules="[{ required: true }]"
|
|
|
- label="消防负责人:"
|
|
|
- placeholder="请填写消防负责人"
|
|
|
- input-align="right"
|
|
|
- />
|
|
|
- </van-cell-group>
|
|
|
- <van-cell-group>
|
|
|
- <van-field
|
|
|
- v-model="inputForm.contactInformation"
|
|
|
- center
|
|
|
- label="联系方式:"
|
|
|
- placeholder="请填写联系方式"
|
|
|
- input-align="right"
|
|
|
- />
|
|
|
- </van-cell-group>
|
|
|
- <van-cell-group>
|
|
|
- <van-field
|
|
|
- v-model="typeOfEmployeesName"
|
|
|
- readonly
|
|
|
- required
|
|
|
- :rules="[{ required: true }]"
|
|
|
- label-width="7.2em"
|
|
|
- label="设备类型:"
|
|
|
- placeholder="请选择设备类型"
|
|
|
- input-align="right"
|
|
|
- right-icon="arrow-down"
|
|
|
- @click="hs_typeOfEmployees = true"
|
|
|
- />
|
|
|
- <van-popup v-model:show="hs_typeOfEmployees" round position="bottom">
|
|
|
- <van-picker
|
|
|
- title="设备类型"
|
|
|
- :columns="$dictUtils.getDictList('hs_site_fire_type')"
|
|
|
- :columns-field-names="{
|
|
|
+ <van-nav-bar fixed title="消防设备添加" left-text="" left-arrow @click-left="onClickLeft"
|
|
|
+ :style="{ 'background-color': selectColor }">
|
|
|
+ </van-nav-bar>
|
|
|
+ <div class="main">
|
|
|
+ <van-form @submit="submit" show-error :show-error-message="false">
|
|
|
+ <van-cell-group>
|
|
|
+ <van-field v-model="inputForm.name" center required :rules="[{ required: true }]" label="设备名称:"
|
|
|
+ placeholder="请填写设备名称" input-align="right" />
|
|
|
+ </van-cell-group>
|
|
|
+ <van-cell-group>
|
|
|
+ <van-field v-model="locationName" readonly required :rules="[{ required: true }]" label="所属场所:"
|
|
|
+ placeholder="请选择所属场所" input-align="right" right-icon="arrow-down" @click="hs_site = true">
|
|
|
+ </van-field>
|
|
|
+ <van-dialog v-model:show="hs_site" title="所属场所" show-cancel-button>
|
|
|
+ <div class="dialog">
|
|
|
+ <van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
|
|
|
+ <van-radio-group v-model="checked">
|
|
|
+ <van-cell-group inset>
|
|
|
+ <van-cell v-for="item in sitelist" :key="item" :title="item.name" clickable
|
|
|
+ @click="getsite(item)">
|
|
|
+ <template #right-icon>
|
|
|
+ <van-radio :name="item.id" @click="getsite(item)" />
|
|
|
+ </template>
|
|
|
+ </van-cell>
|
|
|
+ </van-cell-group>
|
|
|
+ </van-radio-group>
|
|
|
+ </van-list>
|
|
|
+ </div>
|
|
|
+ </van-dialog>
|
|
|
+ </van-cell-group>
|
|
|
+ <van-cell-group>
|
|
|
+ <van-field v-model="inputForm.personInCharge" center required label-width="7.2em"
|
|
|
+ :rules="[{ required: true }]" label="消防负责人:" placeholder="请填写消防负责人" input-align="right" />
|
|
|
+ </van-cell-group>
|
|
|
+ <van-cell-group>
|
|
|
+ <van-field v-model="inputForm.contactInformation" center label="联系方式:" placeholder="请填写联系方式"
|
|
|
+ input-align="right" />
|
|
|
+ </van-cell-group>
|
|
|
+ <van-cell-group>
|
|
|
+ <van-field v-model="typeOfEmployeesName" readonly required :rules="[{ required: true }]"
|
|
|
+ label-width="7.2em" label="设备类型:" placeholder="请选择设备类型" input-align="right" right-icon="arrow-down"
|
|
|
+ @click="hs_typeOfEmployees = true" />
|
|
|
+ <van-popup v-model:show="hs_typeOfEmployees" round position="bottom">
|
|
|
+ <van-picker title="设备类型" :columns="$dictUtils.getDictList('hs_site_fire_type')"
|
|
|
+ :columns-field-names="{
|
|
|
text: 'label',
|
|
|
value: 'value',
|
|
|
- }"
|
|
|
- @cancel="hs_typeOfEmployees = false"
|
|
|
- @confirm="gettypeOfEmployees"
|
|
|
- />
|
|
|
- </van-popup>
|
|
|
- </van-cell-group>
|
|
|
- <van-cell-group>
|
|
|
- <van-field v-model="inputForm.effectiveDateStart" center readonly required label-width="8em"
|
|
|
- :rules="[{ required: true }]" label="有效起始时间:" placeholder="请选择时间"
|
|
|
- input-align="right" right-icon="arrow-down" @click="hs_Start = true" />
|
|
|
- <van-popup v-model:show="hs_Start" round position="bottom">
|
|
|
- <van-picker-group title="有效起始时间" :tabs="['选择日期', '选择时间']" next-step-text="下一步" @confirm="getTime"
|
|
|
- @cancel="hs_Start = false">
|
|
|
- <van-date-picker v-model="currentDate" />
|
|
|
- <van-time-picker v-model="currentTime" :columns-type="columnsType" />
|
|
|
- </van-picker-group>
|
|
|
- </van-popup>
|
|
|
- </van-cell-group>
|
|
|
- <van-cell-group>
|
|
|
- <van-field v-model="inputForm.effectiveDateEnd" center readonly required label-width="8em"
|
|
|
- :rules="[{ required: true }]" label="有效结束时间:" placeholder="请选择时间"
|
|
|
- input-align="right" right-icon="arrow-down" @click="hs_End = true" />
|
|
|
- <van-popup v-model:show="hs_End" round position="bottom">
|
|
|
- <van-picker-group title="有效结束时间" :tabs="['选择日期', '选择时间']" next-step-text="下一步" @confirm="getTimeend"
|
|
|
- @cancel="hs_End = false">
|
|
|
- <van-date-picker v-model="currentDate" />
|
|
|
- <van-time-picker v-model="currentTime" :columns-type="columnsType" />
|
|
|
- </van-picker-group>
|
|
|
- </van-popup>
|
|
|
- </van-cell-group>
|
|
|
- <van-cell-group>
|
|
|
- <van-field v-model="inputForm.nextMaintenanceDate" center readonly label-width="8em"
|
|
|
- label="下次保养时期:" placeholder="请选择时间"
|
|
|
- input-align="right" right-icon="arrow-down" @click="hs_upkeep = true" />
|
|
|
- <van-popup v-model:show="hs_upkeep" round position="bottom">
|
|
|
- <van-picker-group title="下次保养时期" :tabs="['选择日期', '选择时间']" next-step-text="下一步" @confirm="getTimeupkeep"
|
|
|
- @cancel="hs_upkeep = false">
|
|
|
- <van-date-picker v-model="currentDate" />
|
|
|
- <van-time-picker v-model="currentTime" :columns-type="columnsType" />
|
|
|
- </van-picker-group>
|
|
|
- </van-popup>
|
|
|
- </van-cell-group>
|
|
|
- <van-cell-group>
|
|
|
- <van-field
|
|
|
- v-model="inputForm.position"
|
|
|
- center
|
|
|
- required
|
|
|
- :rules="[{ required: true }]"
|
|
|
- label="位置:"
|
|
|
- placeholder="请填写设备位置"
|
|
|
- input-align="right"
|
|
|
- />
|
|
|
- </van-cell-group>
|
|
|
- <van-cell-group>
|
|
|
- <van-field
|
|
|
- name="uploader"
|
|
|
- label-align="top"
|
|
|
- label-width="8em"
|
|
|
- label="设备图片:"
|
|
|
- >
|
|
|
- <template #input>
|
|
|
- <van-uploader
|
|
|
- readonly
|
|
|
- v-model="fileList"
|
|
|
- :max-count="5"
|
|
|
- accept=""
|
|
|
- :preview-full-image="false"
|
|
|
- :before-delete="deleteRead"
|
|
|
- @click-upload="chooseImg"
|
|
|
- >
|
|
|
- </van-uploader>
|
|
|
- </template>
|
|
|
- </van-field>
|
|
|
- </van-cell-group>
|
|
|
- <div class="subbtn">
|
|
|
- <van-button type="primary" native-type="submit">提交</van-button>
|
|
|
- <van-button @click="onClickLeft" type="default" hairline
|
|
|
- >取消</van-button
|
|
|
- >
|
|
|
- </div>
|
|
|
- </van-form>
|
|
|
- </div>
|
|
|
+ }" @cancel="hs_typeOfEmployees = false" @confirm="gettypeOfEmployees" />
|
|
|
+ </van-popup>
|
|
|
+ </van-cell-group>
|
|
|
+ <van-cell-group>
|
|
|
+ <van-field v-model="inputForm.effectiveDateStart" center readonly required label-width="8em"
|
|
|
+ :rules="[{ required: true }]" label="有效起始时间:" placeholder="请选择时间" input-align="right"
|
|
|
+ right-icon="arrow-down" @click="hs_Start = true" />
|
|
|
+ <van-popup v-model:show="hs_Start" round position="bottom">
|
|
|
+ <van-picker-group title="有效起始时间" :tabs="['选择日期', '选择时间']" next-step-text="下一步" @confirm="getTime"
|
|
|
+ @cancel="hs_Start = false">
|
|
|
+ <van-date-picker v-model="currentDate" />
|
|
|
+ <van-time-picker v-model="currentTime" :columns-type="columnsType" />
|
|
|
+ </van-picker-group>
|
|
|
+ </van-popup>
|
|
|
+ </van-cell-group>
|
|
|
+ <van-cell-group>
|
|
|
+ <van-field v-model="inputForm.effectiveDateEnd" center readonly required label-width="8em"
|
|
|
+ :rules="[{ required: true }]" label="有效结束时间:" placeholder="请选择时间" input-align="right"
|
|
|
+ right-icon="arrow-down" @click="hs_End = true" />
|
|
|
+ <van-popup v-model:show="hs_End" round position="bottom">
|
|
|
+ <van-picker-group title="有效结束时间" :tabs="['选择日期', '选择时间']" next-step-text="下一步" @confirm="getTimeend"
|
|
|
+ @cancel="hs_End = false">
|
|
|
+ <van-date-picker v-model="currentDate" />
|
|
|
+ <van-time-picker v-model="currentTime" :columns-type="columnsType" />
|
|
|
+ </van-picker-group>
|
|
|
+ </van-popup>
|
|
|
+ </van-cell-group>
|
|
|
+ <van-cell-group>
|
|
|
+ <van-field v-model="inputForm.nextMaintenanceDate" center readonly label-width="8em" label="下次保养时期:"
|
|
|
+ placeholder="请选择时间" input-align="right" right-icon="arrow-down" @click="hs_upkeep = true" />
|
|
|
+ <van-popup v-model:show="hs_upkeep" round position="bottom">
|
|
|
+ <van-picker-group title="下次保养时期" :tabs="['选择日期', '选择时间']" next-step-text="下一步"
|
|
|
+ @confirm="getTimeupkeep" @cancel="hs_upkeep = false">
|
|
|
+ <van-date-picker v-model="currentDate" />
|
|
|
+ <van-time-picker v-model="currentTime" :columns-type="columnsType" />
|
|
|
+ </van-picker-group>
|
|
|
+ </van-popup>
|
|
|
+ </van-cell-group>
|
|
|
+ <van-cell-group>
|
|
|
+ <van-field v-model="inputForm.position" center required :rules="[{ required: true }]" label="位置:"
|
|
|
+ placeholder="请填写设备位置" input-align="right" />
|
|
|
+ </van-cell-group>
|
|
|
+ <van-cell-group>
|
|
|
+ <van-field name="uploader" label-align="top" label-width="8em" label="设备图片:">
|
|
|
+ <template #input>
|
|
|
+ <van-uploader readonly v-model="fileList" :max-count="5" accept="" :preview-full-image="false"
|
|
|
+ :before-delete="deleteRead" @click-upload="chooseImg">
|
|
|
+ </van-uploader>
|
|
|
+ </template>
|
|
|
+ </van-field>
|
|
|
+ </van-cell-group>
|
|
|
+ <div class="subbtn">
|
|
|
+ <van-button type="primary" native-type="submit">提交</van-button>
|
|
|
+ <van-button @click="onClickLeft" type="default" hairline>取消</van-button>
|
|
|
+ </div>
|
|
|
+ </van-form>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { ref } from "vue";
|
|
|
-import { useRouter } from "vue-router";
|
|
|
-import placeFirefighting from "@/api/placeFirefighting/placeFirefighting";
|
|
|
-import PlaceRegister from "@/api/placeRegister/placeRegister";
|
|
|
-import tools from "@/api/sys/tools";
|
|
|
-import $base from "@/utils/config";
|
|
|
-import { formatDate, formatTime } from "@/utils/datatime";
|
|
|
-export default {
|
|
|
- setup() {
|
|
|
- const inputForm = ref({
|
|
|
- id: "",
|
|
|
- name: "",
|
|
|
- siteId: "",
|
|
|
- personInCharge: "",
|
|
|
- contactInformation: "",
|
|
|
- equipmentType: "",
|
|
|
- devicePicture: "",
|
|
|
- effectiveDate: [],
|
|
|
- effectiveDateStart: "",
|
|
|
- effectiveDateEnd: "",
|
|
|
- nextMaintenanceDate: "",
|
|
|
- position: "",
|
|
|
- });
|
|
|
- // 导航栏颜色
|
|
|
- const selectColor = ref(window.localStorage.getItem("MZ_COLOR"));
|
|
|
- //返回取消按钮
|
|
|
- const onClickLeft = () => {
|
|
|
- history.back();
|
|
|
- };
|
|
|
- // 所属场所
|
|
|
- const locationName = ref("");
|
|
|
- const checked = ref("");
|
|
|
- const sitelist = ref([]);
|
|
|
- let hs_site = ref(false);
|
|
|
- const getsite = (val) => {
|
|
|
- let id = "";
|
|
|
- id = val.id;
|
|
|
- locationName.value = val.name;
|
|
|
- const json = Object.assign(inputForm.value, { siteId: val.id });
|
|
|
- inputForm.value = json;
|
|
|
- checked.value = val.id;
|
|
|
- };
|
|
|
- const loading = ref(false);
|
|
|
- const finished = ref(false);
|
|
|
- const refreshing = ref(false);
|
|
|
- let index = 0;
|
|
|
- const onLoad = () => {
|
|
|
- loading.value = true;
|
|
|
- finished.value = false;
|
|
|
- // 异步更新数据
|
|
|
- new PlaceRegister()
|
|
|
- .religiousList({
|
|
|
- current: index + 1,
|
|
|
- size: 10,
|
|
|
- })
|
|
|
- .then(({ records, pages }) => {
|
|
|
- sitelist.value = sitelist.value.concat(records);
|
|
|
- // 加载状态结束
|
|
|
- loading.value = false;
|
|
|
- if (index + 1 >= pages) {
|
|
|
- finished.value = true;
|
|
|
- }
|
|
|
- index++;
|
|
|
- });
|
|
|
- };
|
|
|
- // 设备类型
|
|
|
- const typeOfEmployeesName = ref("");
|
|
|
- let hs_typeOfEmployees = ref(false);
|
|
|
- const gettypeOfEmployees = ({ selectedOptions }) => {
|
|
|
- hs_typeOfEmployees.value = false;
|
|
|
- const json = Object.assign(inputForm.value, {
|
|
|
- equipmentType: selectedOptions[0].value,
|
|
|
- });
|
|
|
- inputForm.value = json;
|
|
|
- typeOfEmployeesName.value = selectedOptions[0].label;
|
|
|
- };
|
|
|
- //有效期起始时间
|
|
|
- let hs_Start = ref(false);
|
|
|
- let currentDate = ref(formatDate(new Date()));
|
|
|
- let currentTime = ref(formatTime(new Date()));
|
|
|
- const columnsType = ["hour", "minute", "second"];
|
|
|
- const getTime = () => {
|
|
|
- hs_Start.value = false;
|
|
|
- inputForm.value.effectiveDateStart = `${currentDate.value.join(
|
|
|
+ import {
|
|
|
+ ref
|
|
|
+ } from "vue";
|
|
|
+ import {
|
|
|
+ useRouter
|
|
|
+ } from "vue-router";
|
|
|
+ import placeFirefighting from "@/api/placeFirefighting/placeFirefighting";
|
|
|
+ import PlaceRegister from "@/api/placeRegister/placeRegister";
|
|
|
+ import tools from "@/api/sys/tools";
|
|
|
+ import $base from "@/utils/config";
|
|
|
+ import {
|
|
|
+ formatDate,
|
|
|
+ formatTime
|
|
|
+ } from "@/utils/datatime";
|
|
|
+ export default {
|
|
|
+ setup() {
|
|
|
+ const inputForm = ref({
|
|
|
+ id: "",
|
|
|
+ name: "",
|
|
|
+ siteId: "",
|
|
|
+ personInCharge: "",
|
|
|
+ contactInformation: "",
|
|
|
+ equipmentType: "",
|
|
|
+ devicePicture: "",
|
|
|
+ effectiveDate: [],
|
|
|
+ effectiveDateStart: "",
|
|
|
+ effectiveDateEnd: "",
|
|
|
+ nextMaintenanceDate: "",
|
|
|
+ position: "",
|
|
|
+ });
|
|
|
+ // 导航栏颜色
|
|
|
+ const selectColor = ref(window.localStorage.getItem("MZ_COLOR"));
|
|
|
+ //返回取消按钮
|
|
|
+ const onClickLeft = () => {
|
|
|
+ history.back();
|
|
|
+ };
|
|
|
+ // 所属场所
|
|
|
+ const locationName = ref("");
|
|
|
+ const checked = ref("");
|
|
|
+ const sitelist = ref([]);
|
|
|
+ let hs_site = ref(false);
|
|
|
+ const getsite = (val) => {
|
|
|
+ let id = "";
|
|
|
+ id = val.id;
|
|
|
+ locationName.value = val.name;
|
|
|
+ const json = Object.assign(inputForm.value, {
|
|
|
+ siteId: val.id
|
|
|
+ });
|
|
|
+ inputForm.value = json;
|
|
|
+ checked.value = val.id;
|
|
|
+ };
|
|
|
+ const loading = ref(false);
|
|
|
+ const finished = ref(false);
|
|
|
+ const refreshing = ref(false);
|
|
|
+ let index = 0;
|
|
|
+ const onLoad = () => {
|
|
|
+ loading.value = true;
|
|
|
+ finished.value = false;
|
|
|
+ // 异步更新数据
|
|
|
+ new PlaceRegister()
|
|
|
+ .religiousList({
|
|
|
+ current: index + 1,
|
|
|
+ size: 10,
|
|
|
+ })
|
|
|
+ .then(({
|
|
|
+ records,
|
|
|
+ pages
|
|
|
+ }) => {
|
|
|
+ sitelist.value = sitelist.value.concat(records);
|
|
|
+ // 加载状态结束
|
|
|
+ loading.value = false;
|
|
|
+ if (index + 1 >= pages) {
|
|
|
+ finished.value = true;
|
|
|
+ }
|
|
|
+ index++;
|
|
|
+ });
|
|
|
+ };
|
|
|
+ // 设备类型
|
|
|
+ const typeOfEmployeesName = ref("");
|
|
|
+ let hs_typeOfEmployees = ref(false);
|
|
|
+ const gettypeOfEmployees = ({
|
|
|
+ selectedOptions
|
|
|
+ }) => {
|
|
|
+ hs_typeOfEmployees.value = false;
|
|
|
+ const json = Object.assign(inputForm.value, {
|
|
|
+ equipmentType: selectedOptions[0].value,
|
|
|
+ });
|
|
|
+ inputForm.value = json;
|
|
|
+ typeOfEmployeesName.value = selectedOptions[0].label;
|
|
|
+ };
|
|
|
+ //有效期起始时间
|
|
|
+ let hs_Start = ref(false);
|
|
|
+ let currentDate = ref(formatDate(new Date()));
|
|
|
+ let currentTime = ref(formatTime(new Date()));
|
|
|
+ const columnsType = ["hour", "minute", "second"];
|
|
|
+ const getTime = () => {
|
|
|
+ hs_Start.value = false;
|
|
|
+ inputForm.value.effectiveDateStart = `${currentDate.value.join(
|
|
|
"-"
|
|
|
)} ${currentTime.value.join(":")}`;
|
|
|
- };
|
|
|
- //有效期结束时间
|
|
|
- let hs_End = ref(false);
|
|
|
- const getTimeend = () => {
|
|
|
- hs_End.value = false;
|
|
|
- inputForm.value.effectiveDateEnd = `${currentDate.value.join(
|
|
|
+ };
|
|
|
+ //有效期结束时间
|
|
|
+ let hs_End = ref(false);
|
|
|
+ const getTimeend = () => {
|
|
|
+ hs_End.value = false;
|
|
|
+ inputForm.value.effectiveDateEnd = `${currentDate.value.join(
|
|
|
"-"
|
|
|
)} ${currentTime.value.join(":")}`;
|
|
|
- };
|
|
|
- //下次保养日期
|
|
|
- let hs_upkeep = ref(false);
|
|
|
- const getTimeupkeep = () => {
|
|
|
- hs_upkeep.value = false;
|
|
|
- inputForm.value.nextMaintenanceDate = `${currentDate.value.join(
|
|
|
+ };
|
|
|
+ //下次保养日期
|
|
|
+ let hs_upkeep = ref(false);
|
|
|
+ const getTimeupkeep = () => {
|
|
|
+ hs_upkeep.value = false;
|
|
|
+ inputForm.value.nextMaintenanceDate = `${currentDate.value.join(
|
|
|
"-"
|
|
|
)} ${currentTime.value.join(":")}`;
|
|
|
- };
|
|
|
- //图片上传
|
|
|
- let fileList = ref([]);
|
|
|
- let fileImg = ref([]);
|
|
|
- const chooseImg = () => {
|
|
|
- xm.chooseFile({
|
|
|
- count: 1,
|
|
|
- name: "file",
|
|
|
- url:
|
|
|
- $base +
|
|
|
- `/sys/file/webupload/upload?uploadPath=religioussites/fire/fireEquipment`,
|
|
|
- headers: {
|
|
|
- "Content-Type": "multipart/form-data",
|
|
|
- token: window.localStorage.getItem("MZ_TOKEN"),
|
|
|
- },
|
|
|
- }).then((res) => {
|
|
|
- let data = res[0].data;
|
|
|
- data.name = decodeURIComponent(
|
|
|
- data.id.substring(data.url.lastIndexOf("/") + 1)
|
|
|
- );
|
|
|
- data.url = $base + data.url;
|
|
|
- fileImg.value.push(data);
|
|
|
- fileList.value.push(data);
|
|
|
- });
|
|
|
- };
|
|
|
- // 删除文件
|
|
|
- const deleteRead = (file) => {
|
|
|
- //删除文件操作
|
|
|
- for (let index = 0; index < fileList.value.length; index++) {
|
|
|
- if (file.id == fileList.value[index].id) {
|
|
|
- fileList.value.splice(index, 1);
|
|
|
- if (fileImg.value[index]) {
|
|
|
- let delurl = fileImg.value[index].url;
|
|
|
- new tools().uploadFiledelete("", delurl).then(({ data }) => {});
|
|
|
- fileImg.value.splice(index, 1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- let router = useRouter();
|
|
|
- //数据提交
|
|
|
- const submit = () => {
|
|
|
- //保存前附件处理
|
|
|
- inputForm.value.devicePicture = fileImg.value
|
|
|
- .map((option) => option.id)
|
|
|
- .join("|");
|
|
|
- new placeFirefighting()
|
|
|
- .placeFirefightingsave(inputForm.value)
|
|
|
- .then((res) => {
|
|
|
- console.log(res);
|
|
|
- if (res.status == 200) {
|
|
|
- xm.showToast({
|
|
|
- message: "设备添加成功",
|
|
|
- });
|
|
|
- router.push({
|
|
|
- path: "/placeFirefightingList",
|
|
|
- });
|
|
|
- } else {
|
|
|
- xm.showToast({
|
|
|
- message: "设备添加失败",
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- };
|
|
|
- return {
|
|
|
- inputForm,
|
|
|
- selectColor,
|
|
|
- onClickLeft,
|
|
|
- //所属场所
|
|
|
- locationName,
|
|
|
- checked,
|
|
|
- hs_site,
|
|
|
- getsite,
|
|
|
- sitelist,
|
|
|
- loading,
|
|
|
- finished,
|
|
|
- onLoad,
|
|
|
- refreshing,
|
|
|
- //设备类型
|
|
|
- typeOfEmployeesName,
|
|
|
- hs_typeOfEmployees,
|
|
|
- gettypeOfEmployees,
|
|
|
- // 有效起始时间
|
|
|
- currentDate,
|
|
|
- currentTime,
|
|
|
- columnsType,
|
|
|
- hs_Start,
|
|
|
- getTime,
|
|
|
- // 有效结束时间
|
|
|
- hs_End,
|
|
|
- getTimeend,
|
|
|
- // 下次保养日期
|
|
|
- hs_upkeep,
|
|
|
- getTimeupkeep,
|
|
|
- //图片上传
|
|
|
- fileList,
|
|
|
- chooseImg,
|
|
|
- deleteRead,
|
|
|
- //数据提交
|
|
|
- submit,
|
|
|
- };
|
|
|
- },
|
|
|
-};
|
|
|
+ };
|
|
|
+ //图片上传
|
|
|
+ let fileList = ref([]);
|
|
|
+ let fileImg = ref([]);
|
|
|
+ const chooseImg = () => {
|
|
|
+ window.xm.getToken().then(async function(token) {
|
|
|
+ xm.showToast({
|
|
|
+ message: token,
|
|
|
+ });
|
|
|
+ xm.chooseFile({
|
|
|
+ count: 1,
|
|
|
+ name: "file",
|
|
|
+ url: $base +
|
|
|
+ `/sys/file/webupload/upload?uploadPath=religioussites/fire/fireEquipment`,
|
|
|
+ headers: {
|
|
|
+ "Content-Type": "multipart/form-data",
|
|
|
+ token: token,
|
|
|
+ },
|
|
|
+ }).then((res) => {
|
|
|
+ let data = res[0].data;
|
|
|
+ data.name = decodeURIComponent(
|
|
|
+ data.id.substring(data.url.lastIndexOf("/") + 1)
|
|
|
+ );
|
|
|
+ data.url = $base + data.url;
|
|
|
+ fileImg.value.push(data);
|
|
|
+ fileList.value.push(data);
|
|
|
+ });
|
|
|
+ })
|
|
|
+ };
|
|
|
+ // 删除文件
|
|
|
+ const deleteRead = (file) => {
|
|
|
+ //删除文件操作
|
|
|
+ for (let index = 0; index < fileList.value.length; index++) {
|
|
|
+ if (file.id == fileList.value[index].id) {
|
|
|
+ fileList.value.splice(index, 1);
|
|
|
+ if (fileImg.value[index]) {
|
|
|
+ let delurl = fileImg.value[index].url;
|
|
|
+ new tools().uploadFiledelete("", delurl).then(({
|
|
|
+ data
|
|
|
+ }) => {});
|
|
|
+ fileImg.value.splice(index, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ let router = useRouter();
|
|
|
+ //数据提交
|
|
|
+ const submit = () => {
|
|
|
+ //保存前附件处理
|
|
|
+ inputForm.value.devicePicture = fileImg.value
|
|
|
+ .map((option) => option.id)
|
|
|
+ .join("|");
|
|
|
+ new placeFirefighting()
|
|
|
+ .placeFirefightingsave(inputForm.value)
|
|
|
+ .then((res) => {
|
|
|
+ console.log(res);
|
|
|
+ if (res.status == 200) {
|
|
|
+ xm.showToast({
|
|
|
+ message: "设备添加成功",
|
|
|
+ });
|
|
|
+ router.push({
|
|
|
+ path: "/placeFirefightingList",
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ xm.showToast({
|
|
|
+ message: "设备添加失败",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+ return {
|
|
|
+ inputForm,
|
|
|
+ selectColor,
|
|
|
+ onClickLeft,
|
|
|
+ //所属场所
|
|
|
+ locationName,
|
|
|
+ checked,
|
|
|
+ hs_site,
|
|
|
+ getsite,
|
|
|
+ sitelist,
|
|
|
+ loading,
|
|
|
+ finished,
|
|
|
+ onLoad,
|
|
|
+ refreshing,
|
|
|
+ //设备类型
|
|
|
+ typeOfEmployeesName,
|
|
|
+ hs_typeOfEmployees,
|
|
|
+ gettypeOfEmployees,
|
|
|
+ // 有效起始时间
|
|
|
+ currentDate,
|
|
|
+ currentTime,
|
|
|
+ columnsType,
|
|
|
+ hs_Start,
|
|
|
+ getTime,
|
|
|
+ // 有效结束时间
|
|
|
+ hs_End,
|
|
|
+ getTimeend,
|
|
|
+ // 下次保养日期
|
|
|
+ hs_upkeep,
|
|
|
+ getTimeupkeep,
|
|
|
+ //图片上传
|
|
|
+ fileList,
|
|
|
+ chooseImg,
|
|
|
+ deleteRead,
|
|
|
+ //数据提交
|
|
|
+ submit,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ };
|
|
|
</script>
|
|
|
|
|
|
-<style >
|
|
|
-.dialog {
|
|
|
- width: 100%;
|
|
|
- height: 400px;
|
|
|
- overflow: auto;
|
|
|
-}
|
|
|
+<style>
|
|
|
+ .dialog {
|
|
|
+ width: 100%;
|
|
|
+ height: 400px;
|
|
|
+ overflow: auto;
|
|
|
+ }
|
|
|
</style>
|