edit_archive2.vue 10 KB

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