edit_archive1.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <template>
  2. <view class="uni-container">
  3. <view class="example container" :style="'height: ' + (screenHeight - wheight - 75) + 'px'">
  4. <!-- 自定义表单校验 1-->
  5. <u--form ref="customForm" :model="formData" labelPosition="left" labelWidth="100%" labelAlign="left">
  6. <view class=" flex flex-direction width100">
  7. <u-form-item label="居民住宅区名称 " prop="jmzzqmc" :required="true">
  8. <u-input v-model="formData.jmzzqmc" placeholder="必填。请输入居民住宅区名称" />
  9. </u-form-item>
  10. <u-form-item label="联系电话 " prop="lxdh" :required="true">
  11. <u-input v-model="formData.lxdh " placeholder="必填。请输入联系电话" />
  12. </u-form-item>
  13. <u-form-item label="消防安全管理人" prop="xfaqglr" :required="true">
  14. <u-input v-model="formData.xfaqglr" placeholder="必填。请输入消防安全管理人" />
  15. </u-form-item>
  16. <u-form-item label="地址">
  17. <u-input v-model="formData.dz" placeholder="请输入地址" />
  18. </u-form-item>
  19. <u-form-item label="居民人数 " prop="jmrs">
  20. <u-input v-model="formData.jmrs" placeholder="请输入居民人数" />
  21. </u-form-item>
  22. <u-form-item label="进驻时间">
  23. <uni-datetime-picker :show="unitTime" v-model="formData.jzsj" mode="date" closeOnClickOverlay
  24. @confirm="ActiveUnitTime" @cancel="unitTime = false"
  25. @close="unitTime = false"></uni-datetime-picker>
  26. </u-form-item>
  27. <u-form-item label="物业服务企业名称">
  28. <u-input v-model="formData.wymc" placeholder="请输入物业服务企业名称" />
  29. </u-form-item>
  30. <!-- <u-form-item label="*所属乡镇街道" @click="hideKeyboard()" prop="streetName">
  31. <u--input
  32. v-model="formData.streetName"
  33. disabledColor="#ffffff"
  34. disabled
  35. placeholder="请选择所属乡镇街道"
  36. ></u--input>
  37. </u-form-item> -->
  38. <u-form-item label="消防设施器材情况(示例:自动喷水灭火系统、)">
  39. <u-input v-model="formData.xfssqc" placeholder="请输入消防设施器材情况" />
  40. </u-form-item>
  41. <u-form-item label="备注">
  42. <u-textarea auto-height maxlength=-1 v-model="formData.remark" placeholder="请输入备注"></u-textarea>
  43. </u-form-item>
  44. </view>
  45. </u--form>
  46. </view>
  47. <uni-row class="heigthButton">
  48. <u-button @click="submit('customForm')" type="primary" shape="circle" size="large" color="#4CB2B6"
  49. text="确认修改"></u-button>
  50. </uni-row>
  51. </view>
  52. </template>
  53. <script>
  54. import {
  55. updateArchive, // 更新
  56. getDepartment //获取登陆人的部门信息
  57. } from '@/api/archive/index1.js';
  58. var that = null;
  59. export default {
  60. data() {
  61. return {
  62. screenHeight: this.$screenHeight,
  63. wheight: '',
  64. // 每页数据量
  65. pageSize: 5,
  66. // 当前页
  67. pageNo: 1,
  68. // 数据总量
  69. total: 0,
  70. unitTime: false,
  71. loading: false,
  72. title: '生成隐患',
  73. content: '确认将此检查项目生成为隐患',
  74. // 自定义表单数据
  75. formData: {
  76. status: '0',
  77. },
  78. // 自定义表单校验规则
  79. customRules: {
  80. jmzzqmc: {
  81. type: 'string',
  82. required: true,
  83. message: '居民住宅区名称不能为空',
  84. trigger: ['blur', 'change']
  85. },
  86. lxdh: {
  87. pattern: /^((0\d{2,3}-\d{7,8})|(1[3584]\d{9}))$/,
  88. required: true,
  89. message: '联系电话输入不正确',
  90. trigger: ['blur', 'change']
  91. },
  92. xfaqglr: {
  93. type: 'string',
  94. required: true,
  95. message: '消防安全管理人不能为空',
  96. trigger: ['blur', 'change']
  97. },
  98. jmrs: {
  99. type: 'number',
  100. message: '居住人数为数字',
  101. trigger: ['blur', 'change']
  102. },
  103. }
  104. };
  105. },
  106. computed: {},
  107. mounted() {
  108. uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
  109. this.wheight = data.height
  110. }).exec()
  111. },
  112. // 在 vue页面,向起始页通过事件传递数据
  113. onLoad: function(option) {
  114. that = this
  115. var data = option.id;
  116. // 接收来自上个页面传递的参数
  117. const eventChannel = this.getOpenerEventChannel();
  118. eventChannel.on('acceptDataFromOpenerPage', function(val) {
  119. that.formData = val;
  120. });
  121. // 以下内容都是为了 选择街道
  122. const deptValue = uni.getStorageSync('getDepartment_key'); //所有街道
  123. const deptId = uni.getStorageSync('getUserInfo_key')?.streetInfo?.id //登录用户的街道id
  124. // 如果存在街道id,就直接取出对应的名称
  125. if (deptId) {
  126. let newArrar = deptValue.find((item) => {
  127. if (item.id === deptId) {
  128. this.formData.streetId = item.id;
  129. this.formData.streetName = item.name;
  130. }
  131. })
  132. }
  133. },
  134. onReady() {
  135. this.$refs.customForm.setRules(this.customRules);
  136. },
  137. methods: {
  138. submit(ref) {
  139. this.$refs[ref]
  140. .validate()
  141. .then(res => {
  142. this.formData['status'] = 0;
  143. var jsdata = JSON.stringify(this.formData);
  144. console.log(jsdata, 'jsdatajsdatajsdata');
  145. updateArchive(jsdata).then(response => {
  146. console.log('response.data.msg,', response.data);
  147. uni.showLoading({
  148. title: response.data.msg
  149. });
  150. uni.hideLoading();
  151. uni.navigateBack({
  152. delta: 2
  153. })
  154. });
  155. })
  156. .catch(err => {
  157. uni.showToast({
  158. icon: 'none',
  159. title: '错误!' + err[0].message
  160. })
  161. });
  162. },
  163. // 隐藏键盘
  164. hideKeyboard() {
  165. uni.hideKeyboard();
  166. },
  167. // 记录类型
  168. sexSelect2(e) {
  169. this.formData.drillType = e.name;
  170. console.log(this.formData.drillType);
  171. },
  172. // 单位成立时间
  173. ActiveUnitTime(e) {
  174. this.unitTime = false;
  175. let value = new Date(e.value);
  176. console.log(e.value, e.mode);
  177. this.formData.jzsj = uni.$u.timeFormat(e.value, 'yyyy-mm-dd');
  178. },
  179. changetime(e) {
  180. console.log('change', e);
  181. },
  182. // 生成隐患弹出层 //暂存为草稿箱弹出层
  183. cancel() {
  184. this.show = false;
  185. },
  186. confirm() {
  187. setTimeout(() => {
  188. // 0.5秒后自动关闭
  189. this.show = false;
  190. }, 500);
  191. },
  192. // 触底的事件
  193. scrolltolower() {
  194. // 判断是否还有下一页数据
  195. if (this.pageNo * this.pageSize >= this.total)
  196. return uni.showToast({
  197. title: `数据加载完毕`
  198. });
  199. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  200. if (this.loading) return;
  201. this.pageNo += 1;
  202. this.showCheckboxShow(this.pageNo);
  203. }
  204. }
  205. };
  206. </script>
  207. <style lang="scss" scoped>
  208. page {
  209. height: 100%;
  210. background-color: #f5f7f9;
  211. position: relative;
  212. }
  213. body{
  214. background-color: #f5f7f9;
  215. }
  216. .buttomBorder {
  217. height: 0px;
  218. border: 1px dashed #cbd5e1;
  219. }
  220. /deep/ .uni-section .uni-section-header {
  221. padding: 0px;
  222. }
  223. /deep/ .u-form-item__body {
  224. font-weight: 500;
  225. flex-direction: column !important;
  226. }
  227. /deep/ .u-form-item__body__left__content__label {
  228. margin-bottom: 16rpx;
  229. font-size: 30rpx !important;
  230. color: #274647 !important;
  231. }
  232. .arrow-icon {
  233. //主动检查箭头
  234. position: absolute;
  235. right: 14px;
  236. top: 49px;
  237. transform: rotate(90deg);
  238. }
  239. /deep/ .u-input[data-v-fdbb9fe6],
  240. /deep/ .u-input.data-v-fdbb9fe6,
  241. /deep/ .u-input {
  242. background-color: #fff;
  243. }
  244. /deep/.u-button[data-v-3bf2dba7],
  245. /deep/.u-button.data-v-3bf2dba7,
  246. /deep/.u-button {
  247. width: 60% !important;
  248. }
  249. //弹框样式
  250. .btnList {
  251. // width: 40%;
  252. display: flex;
  253. // display:flex;
  254. .u-button[data-v-3bf2dba7],
  255. .u-button {
  256. width: 30%;
  257. }
  258. }
  259. /deep/ .u-popup__content {
  260. //弹出的宽高
  261. height: 100%;
  262. }
  263. /deep/ .u-form-item__body__right__message {
  264. //校验的文字的位置
  265. margin-left: 10rpx !important;
  266. }
  267. /deep/ .uicon-close {
  268. //关闭按钮背景色
  269. background-color: rgba(199, 203, 210, 0.9);
  270. border-radius: 10%;
  271. }
  272. .checkbox {
  273. .checkbox-item {
  274. box-sizing: border-box;
  275. padding-top: 40px;
  276. }
  277. }
  278. //侧边联动
  279. .page-body {
  280. display: flex;
  281. background: #fff;
  282. overflow: hidden;
  283. }
  284. .nav {
  285. display: flex;
  286. width: 100%;
  287. }
  288. .nav-left {
  289. width: 25%;
  290. background: #fafafa;
  291. }
  292. .nav-left-item {
  293. height: 100upx;
  294. border-right: solid 1px #f1f1f1;
  295. border-bottom: solid 1px #f1f1f1;
  296. font-size: 30upx;
  297. display: flex;
  298. align-items: center;
  299. justify-content: center;
  300. }
  301. /deep/.nav-right-item[data-v-73caef23],
  302. /deep/.nav-right-item {
  303. display: flex;
  304. flex-wrap: wrap;
  305. }
  306. .nav-left-item:last-child {
  307. border-bottom: none;
  308. }
  309. .nav-right {
  310. width: 75%;
  311. }
  312. .box {
  313. display: block;
  314. overflow: hidden;
  315. border-bottom: 20upx solid #f3f3f3;
  316. /* min-height: 100vh; */
  317. /*若您的子分类过少想使得每个子分类占满屏请放开上边注视 */
  318. }
  319. .box:last-child {
  320. border: none;
  321. // min-height: 100vh;
  322. }
  323. .nav-right-item {
  324. margin-top: 20px;
  325. // width: 28%;
  326. // min-height: 200upx;
  327. float: left;
  328. text-align: center;
  329. padding: 11upx;
  330. font-size: 28upx;
  331. background: #fff;
  332. /deep/.u-checkbox__icon-wrap[data-v-532d01c7],
  333. /deep/.u-checkbox__icon-wrap {
  334. //复选框的样式
  335. margin: 0 20rpx;
  336. }
  337. /deep/ uni-view[data-v-3d1b15f2] {
  338. //复选框上线的间距
  339. margin: 20rpx 0 !important;
  340. }
  341. // /deep/ .u-checkbox__icon-wrap--square{
  342. // margin: 20rpx;
  343. // }
  344. .u-checkbox-label--right[data-v-532d01c7],
  345. .u-checkbox-label--right {
  346. margin-right: 40rpx;
  347. }
  348. }
  349. .nav-right-item image {
  350. width: 150upx;
  351. height: 150upx;
  352. }
  353. .active {
  354. font-weight: 700;
  355. color: #274647;
  356. background: #fff;
  357. border-right: 0;
  358. }
  359. ::-webkit-scrollbar {
  360. /*取消小程序的默认导航条样式*/
  361. width: 0;
  362. height: 0;
  363. color: transparent;
  364. }
  365. .selectBtn {
  366. width: 200rpx;
  367. margin-left: 0;
  368. font-size: 30rpx;
  369. background-color: #4cb2b6;
  370. }
  371. .example{
  372. overflow-y: auto;
  373. }
  374. </style>