siteInspectionView.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <van-nav-bar
  3. title="信息上报中心"
  4. left-text=""
  5. left-arrow
  6. @click-left="onClickLeft"
  7. />
  8. <div class="main">
  9. <p class="title">场所检查情况上报</p>
  10. <div class="formArea">
  11. <p class="miniTitle">基础信息</p>
  12. <van-cell-group>
  13. <van-field
  14. v-model="siteInspection.siteName.name"
  15. readonly
  16. required
  17. label="场所名称:"
  18. placeholder="请选择"
  19. input-align="right"
  20. right-icon="arrow-down"
  21. @click="showPlace = true"
  22. />
  23. <van-popup v-model:show="showPlace" round position="bottom">
  24. <van-picker
  25. title="场所选择"
  26. :columns="places"
  27. :columns-field-names="customFieldName"
  28. @cancel="showPlace = false"
  29. @confirm="getPlace"
  30. />
  31. </van-popup>
  32. </van-cell-group>
  33. <van-cell-group>
  34. <!-- <van-field
  35. v-model="siteInspection.place"
  36. center
  37. readonly
  38. label="地点:"
  39. placeholder="请填写地点"
  40. input-align="right"
  41. right-icon="arrow-down"
  42. @click="showArea = true"
  43. /> -->
  44. <van-field
  45. v-model="siteInspection.place"
  46. center
  47. readonly
  48. label="地点:"
  49. placeholder="请填写地点"
  50. input-align="right"
  51. right-icon="arrow-down"
  52. />
  53. <van-popup v-model:show="showArea" round position="bottom">
  54. <van-cascader
  55. v-model="cascaderValue"
  56. title="请选择所在地区"
  57. :options="options"
  58. @close="showArea = false"
  59. @finish="onFinish"
  60. :field-names="fieldNames"
  61. />
  62. </van-popup>
  63. </van-cell-group>
  64. <van-cell-group>
  65. <van-field
  66. v-model="siteInspection.placeDel"
  67. center
  68. label="详细地点:"
  69. placeholder="请填写详细地点"
  70. input-align="right"
  71. right-icon="location"
  72. />
  73. </van-cell-group>
  74. <van-cell-group>
  75. <van-field
  76. v-model="siteInspection.supervisionTime"
  77. center
  78. readonly
  79. label="督查时间:"
  80. placeholder="请选择督查时间"
  81. input-align="right"
  82. right-icon="arrow-down"
  83. @click="showAct = true"
  84. />
  85. <van-popup v-model:show="showAct" round position="bottom">
  86. <van-picker-group
  87. title="督查时间"
  88. :tabs="['选择日期', '选择时间']"
  89. next-step-text="下一步"
  90. @confirm="getTime"
  91. @cancel="showAct = false"
  92. >
  93. <van-date-picker v-model="currentDate" />
  94. <van-time-picker v-model="currentTime" :columns-type="columnsType" />
  95. </van-picker-group>
  96. </van-popup>
  97. </van-cell-group>
  98. <van-cell-group>
  99. <van-field name="uploader" label="附件:">
  100. <template #input>
  101. <van-uploader>
  102. <van-button icon="plus">上传文件</van-button>
  103. </van-uploader>
  104. </template>
  105. </van-field>
  106. </van-cell-group>
  107. <van-cell-group>
  108. <div class="rowTextArea">
  109. <van-field
  110. v-model="siteInspection.supervisionContent"
  111. center
  112. rows="2"
  113. type="textarea"
  114. label="督查内容:"
  115. label-align="top"
  116. />
  117. </div>
  118. </van-cell-group>
  119. </div>
  120. <div class="subbtn">
  121. <van-button type="primary" @click="submit">提交</van-button>
  122. <van-button type="default" hairline>取消</van-button>
  123. </div>
  124. </div>
  125. </template>
  126. <script>
  127. import { reactive, ref } from "vue";
  128. import personList from "../personList.vue";
  129. import siteInspectionServer from "@/api/siteInspection/siteInspectionServer";
  130. import tools from "@/api/sys/tools";
  131. export default {
  132. components: { personList },
  133. setup() {
  134. const onClickLeft = () => {
  135. history.back();
  136. };
  137. const siteInspection = reactive({
  138. id: "",
  139. siteName: {
  140. id: "",
  141. },
  142. place: "",
  143. placeDel: "",
  144. supervisionTime: "",
  145. supervisionContent: "",
  146. //附件
  147. enclosure: "",
  148. state: "0",
  149. assessment: "0",
  150. });
  151. // 场所名称
  152. let places = ref([]);
  153. const customFieldName = {
  154. text: "name",
  155. value: "id",
  156. };
  157. new tools()
  158. .placeList({
  159. current: 1,
  160. size: 10000,
  161. })
  162. .then(({ records }) => {
  163. places.value.push(...records);
  164. });
  165. let showPlace = ref(false);
  166. const getPlace = ({ selectedOptions }) => {
  167. showPlace.value = false;
  168. siteInspection.siteName = selectedOptions[0];
  169. console.log(selectedOptions[0].placeSelectName);
  170. siteInspection.place = selectedOptions[0].placeSelectName
  171. };
  172. // 获取督查时间
  173. let showAct = ref(false);
  174. let currentDate = ref(["" + new Date().getFullYear(), "01", "01"]);
  175. let currentTime = ref(["00", "00"]);
  176. const columnsType = ['hour', 'minute', 'second'];
  177. const getTime = () => {
  178. showAct.value = false;
  179. siteInspection.supervisionTime = `${currentDate.value.join(
  180. "-"
  181. )} ${currentTime.value.join(":")}`;
  182. };
  183. let list = {
  184. value: [],
  185. type: "",
  186. };
  187. // 地区选择
  188. let showArea = ref(false);
  189. const cascaderValue = ref("");
  190. const fieldNames = {
  191. text: "name",
  192. value: "code",
  193. children: "children",
  194. };
  195. // 选项列表,children 代表子选项,支持多级嵌套
  196. let options = ref([]);
  197. new tools().treeData().then((res) => {
  198. options.value.push(res[0]);
  199. });
  200. // 全部选项选择完毕后,会触发 finish 事件
  201. const onFinish = ({ selectedOptions }) => {
  202. showArea.value = false;
  203. siteInspection.place = selectedOptions
  204. .map((option) => option.name)
  205. .join("/");
  206. };
  207. // 提交数据
  208. const submit = () => {
  209. //添加保存前判断
  210. new siteInspectionServer().save(siteInspection).then((res) => {
  211. if(res.data=="保存场所检查情况成功"){
  212. console.log("保存成功");
  213. //添加保存后跳转
  214. }
  215. });
  216. };
  217. return {
  218. siteInspection,
  219. // 场所
  220. customFieldName,
  221. showPlace,
  222. places,
  223. getPlace,
  224. // 时间
  225. showAct,
  226. currentDate,
  227. currentTime,
  228. columnsType,
  229. getTime,
  230. // 返回
  231. onClickLeft,
  232. // 地区选择
  233. showArea,
  234. fieldNames,
  235. options,
  236. onFinish,
  237. cascaderValue,
  238. submit,
  239. };
  240. },
  241. };
  242. </script>
  243. <style scoped>
  244. * {
  245. margin: 0;
  246. padding: 0;
  247. }
  248. .main {
  249. background: #fff;
  250. }
  251. .main p {
  252. height: 40px;
  253. line-height: 40px;
  254. color: #36a7f3;
  255. border-bottom: 1px solid #eee;
  256. }
  257. .title {
  258. font-size: 20px;
  259. font-weight: 700;
  260. padding-left: 20px;
  261. }
  262. .miniTitle {
  263. font-size: 16px;
  264. }
  265. .formArea {
  266. padding: 0px 20px;
  267. }
  268. .formArea .van-cell-group .van-field__label {
  269. height: 40px;
  270. }
  271. .formArea .van-cell-group .van-cell {
  272. line-height: 40px;
  273. }
  274. .van-cell__value .van-field__right-icon .van-icon-location {
  275. color: #36a7f3 !important;
  276. }
  277. .rowTextArea::v-deep .van-field__value {
  278. width: 94%;
  279. border: 2px solid #ccc;
  280. border-radius: 10px;
  281. padding: 10px;
  282. }
  283. .rowTextArea::v-deep .van-cell {
  284. display: flow-root;
  285. }
  286. .subbtn {
  287. margin: 20px;
  288. text-align: center;
  289. }
  290. .subbtn .van-button {
  291. width: 40%;
  292. margin: 5px;
  293. }
  294. .van-uploader .van-button {
  295. border: none;
  296. color: #36a7f3;
  297. top: -4px;
  298. }
  299. .van-dialog {
  300. width: 80%;
  301. top: 50%;
  302. }
  303. </style>