edit_archive2.vue 9.5 KB

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