edit_archive6.vue 8.5 KB

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