123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- <template>
- <van-nav-bar
- title="信息上报中心"
- left-text=""
- left-arrow
- @click-left="onClickLeft"
- />
- <div class="main">
- <p class="title">场所检查情况上报</p>
- <div class="formArea">
- <p class="miniTitle">基础信息</p>
- <van-cell-group>
- <van-field
- v-model="siteInspection.siteName.name"
- readonly
- required
- label="场所名称:"
- placeholder="请选择"
- input-align="right"
- right-icon="arrow-down"
- @click="showPlace = true"
- />
- <van-popup v-model:show="showPlace" round position="bottom">
- <van-picker
- title="场所选择"
- :columns="places"
- :columns-field-names="customFieldName"
- @cancel="showPlace = false"
- @confirm="getPlace"
- />
- </van-popup>
- </van-cell-group>
- <van-cell-group>
- <!-- <van-field
- v-model="siteInspection.place"
- center
- readonly
- label="地点:"
- placeholder="请填写地点"
- input-align="right"
- right-icon="arrow-down"
- @click="showArea = true"
- /> -->
- <van-field
- v-model="siteInspection.place"
- center
- readonly
- label="地点:"
- placeholder="请填写地点"
- input-align="right"
- right-icon="arrow-down"
- />
- <van-popup v-model:show="showArea" round position="bottom">
- <van-cascader
- v-model="cascaderValue"
- title="请选择所在地区"
- :options="options"
- @close="showArea = false"
- @finish="onFinish"
- :field-names="fieldNames"
- />
- </van-popup>
- </van-cell-group>
- <van-cell-group>
- <van-field
- v-model="siteInspection.placeDel"
- center
- label="详细地点:"
- placeholder="请填写详细地点"
- input-align="right"
- right-icon="location"
- />
- </van-cell-group>
- <van-cell-group>
- <van-field
- v-model="siteInspection.supervisionTime"
- center
- readonly
- label="督查时间:"
- placeholder="请选择督查时间"
- input-align="right"
- right-icon="arrow-down"
- @click="showAct = true"
- />
- <van-popup v-model:show="showAct" round position="bottom">
- <van-picker-group
- title="督查时间"
- :tabs="['选择日期', '选择时间']"
- next-step-text="下一步"
- @confirm="getTime"
- @cancel="showAct = 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 name="uploader" label="附件:">
- <template #input>
- <van-uploader>
- <van-button icon="plus">上传文件</van-button>
- </van-uploader>
- </template>
- </van-field>
- </van-cell-group>
- <van-cell-group>
- <div class="rowTextArea">
- <van-field
- v-model="siteInspection.supervisionContent"
- center
- rows="2"
- type="textarea"
- label="督查内容:"
- label-align="top"
- />
- </div>
- </van-cell-group>
- </div>
- <div class="subbtn">
- <van-button type="primary" @click="submit">提交</van-button>
- <van-button type="default" hairline>取消</van-button>
- </div>
- </div>
- </template>
- <script>
- import { reactive, ref } from "vue";
- import personList from "../personList.vue";
- import siteInspectionServer from "@/api/siteInspection/siteInspectionServer";
- import tools from "@/api/sys/tools";
- export default {
- components: { personList },
- setup() {
- const onClickLeft = () => {
- history.back();
- };
- const siteInspection = reactive({
- id: "",
- siteName: {
- id: "",
- },
- place: "",
- placeDel: "",
- supervisionTime: "",
- supervisionContent: "",
- //附件
- enclosure: "",
- state: "0",
- assessment: "0",
- });
- // 场所名称
- let places = ref([]);
- const customFieldName = {
- text: "name",
- value: "id",
- };
- new tools()
- .placeList({
- current: 1,
- size: 10000,
- })
- .then(({ records }) => {
- places.value.push(...records);
- });
- let showPlace = ref(false);
- const getPlace = ({ selectedOptions }) => {
- showPlace.value = false;
- siteInspection.siteName = selectedOptions[0];
- console.log(selectedOptions[0].placeSelectName);
- siteInspection.place = selectedOptions[0].placeSelectName
- };
- // 获取督查时间
- let showAct = ref(false);
- let currentDate = ref(["" + new Date().getFullYear(), "01", "01"]);
- let currentTime = ref(["00", "00"]);
- const columnsType = ['hour', 'minute', 'second'];
- const getTime = () => {
- showAct.value = false;
- siteInspection.supervisionTime = `${currentDate.value.join(
- "-"
- )} ${currentTime.value.join(":")}`;
- };
- let list = {
- value: [],
- type: "",
- };
- // 地区选择
- let showArea = ref(false);
- const cascaderValue = ref("");
- const fieldNames = {
- text: "name",
- value: "code",
- children: "children",
- };
- // 选项列表,children 代表子选项,支持多级嵌套
- let options = ref([]);
- new tools().treeData().then((res) => {
- options.value.push(res[0]);
- });
- // 全部选项选择完毕后,会触发 finish 事件
- const onFinish = ({ selectedOptions }) => {
- showArea.value = false;
- siteInspection.place = selectedOptions
- .map((option) => option.name)
- .join("/");
- };
- // 提交数据
- const submit = () => {
- //添加保存前判断
- new siteInspectionServer().save(siteInspection).then((res) => {
- if(res.data=="保存场所检查情况成功"){
- console.log("保存成功");
- //添加保存后跳转
- }
- });
- };
- return {
- siteInspection,
- // 场所
- customFieldName,
- showPlace,
- places,
- getPlace,
- // 时间
- showAct,
- currentDate,
- currentTime,
- columnsType,
- getTime,
- // 返回
- onClickLeft,
- // 地区选择
- showArea,
- fieldNames,
- options,
- onFinish,
- cascaderValue,
- submit,
- };
- },
- };
- </script>
- <style scoped>
- * {
- margin: 0;
- padding: 0;
- }
- .main {
- background: #fff;
- }
- .main p {
- height: 40px;
- line-height: 40px;
- color: #36a7f3;
- border-bottom: 1px solid #eee;
- }
- .title {
- font-size: 20px;
- font-weight: 700;
- padding-left: 20px;
- }
- .miniTitle {
- font-size: 16px;
- }
- .formArea {
- padding: 0px 20px;
- }
- .formArea .van-cell-group .van-field__label {
- height: 40px;
- }
- .formArea .van-cell-group .van-cell {
- line-height: 40px;
- }
- .van-cell__value .van-field__right-icon .van-icon-location {
- color: #36a7f3 !important;
- }
- .rowTextArea::v-deep .van-field__value {
- width: 94%;
- border: 2px solid #ccc;
- border-radius: 10px;
- padding: 10px;
- }
- .rowTextArea::v-deep .van-cell {
- display: flow-root;
- }
- .subbtn {
- margin: 20px;
- text-align: center;
- }
- .subbtn .van-button {
- width: 40%;
- margin: 5px;
- }
- .van-uploader .van-button {
- border: none;
- color: #36a7f3;
- top: -4px;
- }
- .van-dialog {
- width: 80%;
- top: 50%;
- }
- </style>
|