add_check.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131
  1. <template>
  2. <view class="container uni-container">
  3. <view class="example">
  4. <!-- 自定义表单校验 1-->
  5. <u--form ref="customForm" :model="formData" labelPosition="left" labelWidth="70" labelAlign="right">
  6. <view class=" flex flex-direction ">
  7. <u-form-item label="任务名称" prop="taskName" :required="true">
  8. <u-input v-model="formData.taskName" placeholder="请输入项目名称" />
  9. </u-form-item>
  10. <u-form-item label="所属单位" prop="orgId" @click="showSex(); hideKeyboard()" :required="true">
  11. <u--input suffixIcon="arrow-right" suffixIconStyle="color: #909399" v-model="formData.orgId"
  12. disabled disabledColor="#ffffff" placeholder="请选择所属单位">
  13. </u--input>
  14. </u-form-item>
  15. <!-- <u-form-item label="所属部门" prop="deptId" @click="showSex3(); hideKeyboard()">
  16. <u--input suffixIcon="arrow-right" suffixIconStyle="color: #909399" v-model="formData.deptId"
  17. disabled disabledColor="#ffffff" placeholder="请选择所属部门 (注:单位/部门二选一)">
  18. </u--input>
  19. </u-form-item> -->
  20. <u-form-item label="检查项目" :required="true" prop="inspectIds"
  21. @click="showCheckboxShow(); hideKeyboard()">
  22. <u--input suffixIcon="arrow-right" suffixIconStyle="color: #909399"
  23. v-model="formData.inspectIds" disabled disabledColor="#ffffff" placeholder="请选择检查项目">
  24. </u--input>
  25. </u-form-item>
  26. </view>
  27. <u-form-item label="巡查内容补充" prop="taskContent" class="xuncha" label-width="220rpx">
  28. <u--textarea v-model="formData.taskContent" placeholder="请输入内容" :maxlength="200" count height="100">
  29. </u--textarea>
  30. </u-form-item>
  31. <u-form-item label="上传附件">
  32. <!-- 选择文件上传,limit="1则最多选择一张图片,del-icon隐藏删除按钮 -->
  33. <uni-file-picker v-model="formData.attId" del-icon limit="1" auto-upload file-mediatype="all"
  34. @select="select" @delete="deleteFile">
  35. <button type="primary" class="selectBtn">选择文件</button>
  36. <!-- 加载中 -->
  37. <isLodingModel v-if="loading"></isLodingModel>
  38. </uni-file-picker>
  39. </u-form-item>
  40. <u-form-item label="已上传附件" v-if="bianji&&formData.attId.length" labelWidth="120">
  41. <u-icon name="close" color="#4CB2B6" size="24" @click="closeImage()">
  42. </u-icon>
  43. <!-- #ifdef MP-WEIXIN -->
  44. <text style="color:#00a3f4;cursor: pointer;margin-left: 50rpx !important;"
  45. @click.native="viewSee(formData.attId[0])">点击预览文件</text>
  46. <!-- #endif -->
  47. <!-- #ifdef H5 -->
  48. <a style="color:#00a3f4;cursor: pointer;margin-left: 50rpx !important;"
  49. @click="viewSee(formData.attId[0])">点击预览文件</a>
  50. <!-- #endif -->
  51. </u-form-item>
  52. <uni-row class="zan-cun">
  53. <!-- <uni-col :span="12">
  54. <u-button @click="submit('customForm')" type="primary" shape="circle" size="default"
  55. color="#4CB2B6" text="立即发布">
  56. :text="bianji?'确认修改':'确认提交'"
  57. </u-button>
  58. </uni-col> -->
  59. <uni-col :span="24">
  60. <!-- <u-modal :show="show" :title="title" :content='content' :asyncClose="true" @cancel="cancel"
  61. @confirm="confirm" :showCancelButton='true' :showConfirmButton='true'></u-modal> -->
  62. <u-button @click="submit('customForm')" type="primary" color="#4CB2B6" shape="circle"
  63. size="default" text="暂存"></u-button>
  64. <u-modal :show="showNew" title="已存入草稿箱,是否立即发布" @confirm="sureNew" @cancel="cancelNew"
  65. :showCancelButton='true' :showConfirmButton='true'></u-modal>
  66. </uni-col>
  67. </uni-row>
  68. </u--form>
  69. <!-- 多选closeable closeOnClickOverlay--点击遮罩层不可关闭所属单位的弹出内容选中 ,选择单位-->
  70. <u-popup :show="checkboxShow2" :round="10" @close="checkboxShow2=false" style="position: relative;">
  71. <!-- <view class="u-page__tag-item">
  72. <u-search placeholder="请输入所属单位" v-model="keyword" bgColor="#edf6f9" borderColor="#4cb2b6"
  73. :show-action="false"></u-search>
  74. </view> -->
  75. <view class="popup-button">
  76. <uni-row>
  77. <uni-col :span='12'>
  78. <u-button shape="circle" type="primary" color="#4CB2B6" text="确定" @click="checkboxConfirm2">
  79. </u-button>
  80. </uni-col>
  81. <uni-col :span='12'>
  82. <u-button type="primary" plain color="#4CB2B6" text="取消" shape="circle"
  83. @click="checkboxCancel2">
  84. </u-button>
  85. </uni-col>
  86. </uni-row>
  87. </view>
  88. <view class="page-body" :style="'height:' + (height-80)+ 'px'">
  89. <scroll-view class="nav-left" scroll-y :style="'height:' + height + 'px'"
  90. :scroll-top="scrollLeftTop" scroll-with-animation>
  91. <view class="nav-left-item" :class="index == categoryActive ? 'active' : ''"
  92. v-for="(item, index) in list2" @click="categoryClickMain(index,item)" :key="index">
  93. {{item[0]}}
  94. </view>
  95. </scroll-view>
  96. <scroll-view class="nav-right" scroll-y :scroll-top="scrollTop" @scroll="scroll"
  97. :style="'height:' + height + 'px'" scroll-with-animation>
  98. <view v-for="(item, index) in list2" :key="index" class="box">
  99. <view style="height: 60rpx;font-size: 32rpx;color:#000;font-weight: 600;padding: 25rpx;">
  100. {{ item[0]}}
  101. </view>
  102. <!-- <view :id="i == 0 ? 'first' : ''" class="nav-right-item"> -->
  103. <view class="nav-right-item">
  104. <u-checkbox-group size='20' iconSize='18' placement="row" iconPlacement='right'
  105. v-model="items.checkedList2" v-for="(items, i) in item" :key="i"
  106. @change="checkboxChange2(items.dwid,$event)">
  107. <u-checkbox v-if="i>0" activeColor="green" :customStyle="{marginBottom: '5px'}"
  108. :label="items.orgName" :name="items.dwid">
  109. </u-checkbox>
  110. </u-checkbox-group>
  111. </view>
  112. </view>
  113. </scroll-view>
  114. </view>
  115. </u-popup>
  116. <!-- 多选closeable closeOnClickOverlay--点击遮罩层不可关闭检查项的弹出内容选中 选择检查项-->
  117. <u-popup :show="checkboxShow" :round="10" @close="checkboxShow=false" style="position: relative;">
  118. <!-- <view class="u-page__tag-item">
  119. <u-search placeholder="请输入检查项" v-model="keyword" bgColor="#edf6f9" borderColor="#4cb2b6"
  120. :show-action="false"></u-search>
  121. </view> -->
  122. <view class="popup-button heigthButton">
  123. <uni-row>
  124. <uni-col :span='12'>
  125. <u-button shape="circle" type="primary" color="#4CB2B6" text="确定" @click="checkboxConfirm">
  126. </u-button>
  127. </uni-col>
  128. <uni-col :span='12'>
  129. <u-button type="primary" plain color="#4CB2B6" text="取消" shape="circle"
  130. @click="checkboxCancel">
  131. </u-button>
  132. </uni-col>
  133. </uni-row>
  134. </view>
  135. <view class="page-body" :style="'height:' +(height -80) + 'px'">
  136. <scroll-view class="nav-left" scroll-y :style="'height:' + (height -80) + 'px'"
  137. :scroll-top="scrollLeftTop" scroll-with-animation>
  138. <view class="nav-left-item" :class="index == categoryActive ? 'active' : ''"
  139. v-for="(item, index) in list" @click="categoryClickMain(index,item)" :key="index">
  140. {{ item.label }}
  141. </view>
  142. </scroll-view>
  143. <scroll-view class="nav-right" scroll-y :scroll-top="scrollTop" @scroll="scroll"
  144. :style="'height:' +(height -140) + 'px'" scroll-with-animation>
  145. <view v-for="(item, index) in list" :key="index" class="box" ref="rightItem">
  146. <view style="height: 60rpx;font-size: 32rpx;color:#000;font-weight: 600;padding: 25rpx;">
  147. {{item.label}}
  148. </view>
  149. <!-- <view :id="i == 0 ? 'first' : ''" class="nav-right-item"> -->
  150. <view class="nav-right-item">
  151. <u-checkbox-group size='20' iconSize='18' placement="row" iconPlacement='right'
  152. v-model="items.checkedList" v-for="(items, i) in item.inspectInfoDOList" :key="i"
  153. @change="checkboxChange(items.id,$event)">
  154. <u-checkbox activeColor="green" :customStyle="{marginBottom: '5px'}"
  155. :label="items.inspName" :name="items.id">
  156. </u-checkbox>
  157. </u-checkbox-group>
  158. </view>
  159. </view>
  160. </scroll-view>
  161. </view>
  162. </u-popup>
  163. <!-- 多选closeable closeOnClickOverlay--点击遮罩层不可关闭所属部门的弹出内容选中 ,选择部门-->
  164. <u-popup :show="checkboxShow3" :round="10" @close="checkboxShow3=false" style="position: relative;">
  165. <view class="popup-button heigthButton">
  166. <uni-row>
  167. <uni-col :span='12'>
  168. <u-button shape="circle" type="primary" color="#4CB2B6" text="确定" @click="checkboxConfirm3">
  169. </u-button>
  170. </uni-col>
  171. <uni-col :span='12'>
  172. <u-button type="primary" plain color="#4CB2B6" text="取消" shape="circle"
  173. @click="checkboxCancel3">
  174. </u-button>
  175. </uni-col>
  176. </uni-row>
  177. </view>
  178. <view class="page-body" :style="'height:' + (height - wheight- 80) + 'px'">
  179. <scroll-view class="nav-left" scroll-y :style="'height:' + (height- 80) + 'px'"
  180. :scroll-top="scrollLeftTop" scroll-with-animation>
  181. <view class="nav-left-item" :class="index == categoryActive ? 'active' : ''"
  182. v-for="(item, index) in list3Jia" @click="categoryClickMain(index,item)" :key="index">
  183. {{ item.name}}
  184. </view>
  185. </scroll-view>
  186. <scroll-view class="nav-right" scroll-y :scroll-top="scrollTop" @scroll="scroll"
  187. :style="'height:' +( height-140) + 'px'" scroll-with-animation>
  188. <view v-for="(item, index) in list3Jia" :key="index" class="box">
  189. <view style="height: 60rpx;font-size: 32rpx;color:#000;font-weight: 600;padding: 25rpx;">
  190. {{ `单位${item.id}` }}
  191. </view>
  192. <!-- <view :id="i == 0 ? 'first' : ''" class="nav-right-item"> -->
  193. <view class="nav-right-item">
  194. <u-checkbox-group size='20' iconSize='18' placement="row" iconPlacement='right'
  195. v-model="items.checkedList3" v-for="(items, i) in list3" :key="i"
  196. @change="checkboxChange3(items.id,$event)">
  197. <u-checkbox activeColor="green" :customStyle="{marginBottom: '5px'}"
  198. :label="items.name" :name="items.id">
  199. </u-checkbox>
  200. </u-checkbox-group>
  201. </view>
  202. </view>
  203. </scroll-view>
  204. </view>
  205. </u-popup>
  206. <!-- <image :src="jiezhiTime" mode="heightFix" style="width: 20px;height: 20px;"></image> -->
  207. </view>
  208. </view>
  209. </template>
  210. <script>
  211. import {
  212. addCheckActiveCreate, // 主动检查添加
  213. addCheckActiveErrorsubmit, // 主动检查生成隐患
  214. addCheckActiveCompany, //所属单位
  215. jiase, //检查项数据列表
  216. addCheckActiveDepartment, //所属部门
  217. editCheckActiveCreate, //编辑主动检查
  218. getCheckActiveTask, //获取编辑主动检查的数据
  219. getCheckActiveTaskXin, //最新--获取编辑主动检查的数据
  220. saveCheckRelease
  221. } from "@/api/check_active";
  222. import {
  223. uploadAvatar
  224. } from "@/api/system/user"
  225. import {
  226. getAccessToken
  227. } from '@/utils/auth'
  228. import {
  229. downSee,
  230. checkType
  231. } from '@/utils/common'
  232. import config from '@/config'
  233. import store from "@/store"
  234. const baseUrl = config.baseUrl
  235. let that = null;
  236. export default {
  237. data() {
  238. return {
  239. wheight: '',
  240. keyword: '',
  241. list3Jia: [{
  242. name: '测试部门'
  243. }],
  244. showNew: false, //确认立即发布弹框
  245. showGender: false, //所属单位下拉框展示
  246. //————————————下拉结束
  247. checkboxShow: false, //选择检查项目弹框
  248. checkboxShow2: false, //选择检查单位弹框
  249. checkboxShow3: false, //选择检查部门弹框
  250. checkedList: [], //检查项目已选择列表
  251. checkedList2: [], //检查单位已选择列表
  252. checkedList3: [], //检查部门已选择列表
  253. // 生成隐患弹窗
  254. show: false,
  255. list: [], //选择检查项目的数据
  256. list2: [], //选择单位项目的数据
  257. list3: [], //选择单位项目的数据
  258. // 每页数据量
  259. pageSize: 5,
  260. // 当前页
  261. pageNo: 1,
  262. // 数据总量
  263. total: 0,
  264. // tableData数据加载中
  265. tableData: '',
  266. loading: false,
  267. title: '生成隐患',
  268. content: '确认将此检查项目生成为隐患',
  269. // 自定义表单数据
  270. formData: {
  271. taskName: '', //任务名称
  272. inspectIds: '', //检查项目
  273. taskContent: '', //任务描述
  274. orgId: '', //页面上显示的检查单位
  275. deptId: '', //页面上显示的部门
  276. attId: [], //附件
  277. },
  278. formDataChuangMu: {
  279. "deptId": [],
  280. // "attId": 0,
  281. "inspectIds": [],
  282. "orgId": [], //检查单位id
  283. // "orgType": "",
  284. "status": 0, //0代表启用
  285. "taskContent": "", //任务描述
  286. "sender": this.$store.state.user.id,
  287. // "taskId": 0,
  288. "taskName": "", //任务名称
  289. // "taskScore": 0,
  290. "taskStatus": "0",
  291. "taskType": "", //任务类型 1对应主动检查
  292. "attId": ''
  293. },
  294. fileList1: [],
  295. // 自定义表单校验规则
  296. customRules: {
  297. taskName: {
  298. status: 'string',
  299. required: true,
  300. message: '任务名称需在2-20个字符之间',
  301. trigger: ['blur', 'change'],
  302. min: 2,
  303. max: 20,
  304. },
  305. inspectIds: {
  306. status: 'string',
  307. required: true,
  308. message: '检查项目不能为空',
  309. trigger: ['blur', 'change']
  310. },
  311. orgId: {
  312. status: 'string',
  313. required: true,
  314. message: '所属单位不能为空',
  315. trigger: ['blur', 'change']
  316. },
  317. // deptId:{
  318. // status: 'string',
  319. // required: true,
  320. // message: '所属部门不能为空',
  321. // trigger: ['blur', 'change']
  322. // }
  323. },
  324. categoryActiveIndex: 0,
  325. bianji: false, //是否编辑进来的
  326. ids: '', //创建成功的id
  327. //侧边栏联动
  328. height: 0,
  329. categoryActive: 0,
  330. scrollTop: 0,
  331. scrollLeftTop: 0,
  332. arr: [],
  333. // arr: [0, 584, 1168, 1752, 2336, 2805, 3274, 3858, 4442, 4911, 5380, 5734, 6203, 6672,
  334. // 7017
  335. // ], //初始值,后边计算会根据手机适配覆盖
  336. leftItemHeight: 51, //49行会计算出新值进行覆盖
  337. navLeftHeight: 0, //左边scroll-view 内层nav的总高度
  338. diff: 0, //左边scroll-view 内层nav的总高度与视口之差
  339. tabBarHeight: 0, //如果此页面为Tab页面,自己改变高度值,,一般tab高度为51
  340. }
  341. },
  342. computed: {},
  343. watch: {
  344. loading: {
  345. handler(newLength, oldLength) {
  346. this.$modal.isLoadingModel(this.loading)
  347. },
  348. immediate: true
  349. }
  350. },
  351. // 在 vue页面,向起始页通过事件传递数据
  352. onLoad: function(option) {
  353. this.formDataChuangMu.taskType = option.type
  354. if (option.id) {
  355. this.bianji = true
  356. const ids = parseInt(option.id)
  357. const json = JSON.stringify({
  358. id: ids,
  359. // pageNo: this.pageNo,
  360. // pagesSize: this.pageSize
  361. })
  362. getCheckActiveTaskXin({
  363. id: ids
  364. }).then(response => { //获取编辑主动检查的数据
  365. const res = response.data
  366. this.formData.taskName = res.taskInfo.taskName
  367. this.formData.taskContent = res.taskInfo.taskContent
  368. this.formData.attId[0] = res.taskInfo.attId ? res.taskInfo.attId : ''
  369. this.formDataChuangMu.attId = res.taskInfo.attId ? res.taskInfo.attId : ''
  370. if (res.orgList && res.orgList.length != 0) {
  371. let item = []
  372. res.orgList.map(v => { //单位
  373. this.formDataChuangMu.orgId.push(v.id)
  374. item.push(v.orgName)
  375. })
  376. this.formData.orgId = item.join(',')
  377. }
  378. if (res.inspectList.length != 0) {
  379. let arr = []
  380. res.inspectList.map(v => { //项目
  381. this.formDataChuangMu.inspectIds.push(v.id)
  382. arr.push(v.inspName)
  383. })
  384. this.formData.inspectIds = arr.join(',')
  385. }
  386. // if (res.deptList.length != 0) {
  387. // this.formData.deptId = '已选择部门'
  388. // res.deptList.map(v => { //部门
  389. // this.formDataChuangMu.deptId.push(v.id)
  390. // })
  391. // }
  392. });
  393. this.formDataChuangMu["id"] = ids
  394. }
  395. },
  396. onReady() {
  397. // this.checkedTotal3(this.pageNo) 部门
  398. this.checkedTotal(this.pageNo)
  399. this.getData(this.pageNo)
  400. this.height = uni.getSystemInfoSync().windowHeight - this.tabBarHeight
  401. // 设置自定义表单校验规则,必须在节点渲染完毕后执行
  402. this.$refs.customForm.setRules(this.customRules)
  403. },
  404. methods: {
  405. closeImage() {
  406. this.formData.attId = []
  407. this.formDataChuangMu.attId = ''
  408. this.$forceUpdate()
  409. },
  410. //查看已上传附件
  411. viewSee(val) {
  412. downSee(val)
  413. },
  414. //上传文件
  415. selectBtn() {
  416. this.$refs.files.upload()
  417. },
  418. // 隐藏键盘
  419. hideKeyboard() {
  420. uni.hideKeyboard()
  421. },
  422. // 生成隐患弹出层 //暂存为草稿箱弹出层
  423. cancel() {
  424. this.show = false;
  425. },
  426. confirm() {
  427. setTimeout(() => {
  428. // 0.5秒后自动关闭
  429. this.show = false;
  430. }, 500)
  431. },
  432. //popup检查项确定
  433. checkboxConfirm() {
  434. this.checkboxShow = false
  435. let arr = []
  436. this.checkedList.map(v => {
  437. v.map(i => {
  438. arr.push(i)
  439. })
  440. })
  441. this.formDataChuangMu.inspectIds = [...new Set(arr)]
  442. let items = []
  443. if (this.checkedList.length != 0) {
  444. this.list.map(i => {
  445. i.inspectInfoDOList.map(k => {
  446. this.formDataChuangMu.inspectIds.map(j => {
  447. if (k.id == j) {
  448. items.push(k.inspName)
  449. }
  450. })
  451. })
  452. })
  453. this.formData.inspectIds = items.join(',')
  454. } else {
  455. this.formData.inspectIds = ''
  456. }
  457. },
  458. //popup取消
  459. checkboxCancel() {
  460. this.checkboxShow = false
  461. this.checkedList = []
  462. this.formData.inspectIds = ''
  463. },
  464. //popup检查单位确定============
  465. checkboxConfirm2() {
  466. this.checkboxShow2 = false
  467. let arr = []
  468. this.checkedList2.map(v => {
  469. v.map(i => {
  470. arr.push(i)
  471. })
  472. })
  473. this.formDataChuangMu.orgId = [...new Set(arr)]
  474. let items = []
  475. if (this.checkedList2.length != 0) {
  476. for (let v in this.list2) {
  477. this.list2[v].map(i => {
  478. // i.map(k => {
  479. this.formDataChuangMu.orgId.map(j => {
  480. if (i.dwid == j) {
  481. items.push(i.orgName)
  482. }
  483. })
  484. // })
  485. })
  486. }
  487. this.formData.orgId = items.join(',')
  488. } else {
  489. this.formData.orgId = ''
  490. }
  491. },
  492. //popup取消
  493. checkboxCancel2() {
  494. this.checkboxShow2 = false
  495. this.checkedList2 = []
  496. this.formData.orgId = ''
  497. },
  498. //========
  499. // //popup检查部门确定============
  500. // checkboxConfirm3() {
  501. // this.checkboxShow3 = false
  502. // this.checkedList3.map(v => {
  503. // v.map(i => {
  504. // this.formDataChuangMu.deptId.push(i)
  505. // })
  506. // })
  507. // if (this.checkedList3.length != 0) {
  508. // this.formData.deptId = '已选择部门'
  509. // }else{
  510. // this.formData.deptId =''
  511. // }
  512. // },
  513. // //popup取消
  514. // checkboxCancel3() {
  515. // this.checkboxShow3 = false
  516. // this.checkedList3 = []
  517. // this.formData.deptId =''
  518. // },
  519. // checkboxChange3(i, n) {
  520. // if (i && n.length != 0) {
  521. // this.checkedList3.push(n)
  522. // } else if (i && n.length == 0) {
  523. // this.checkedList3 = this.checkedList3.filter(item => item != i)
  524. // }
  525. // console.log(this.checkedList3, 'this.checkedList3');
  526. // },
  527. // // 展示部门选择的弹出层
  528. // showSex3(pageNo, value = '') {
  529. // this.checkboxShow3 = true
  530. // },
  531. // checkedTotal3(pageNo) { //部门
  532. // this.loading = true
  533. // this.pageNo = pageNo
  534. // addCheckActiveDepartment({}).then(response => { //所属部门数据列表
  535. // console.log(response, 'response部门');
  536. // this.list3 = response.data
  537. // console.log(this.list3, 'this.list3');
  538. // const json = JSON.stringify({
  539. // id: this.formDataChuangMu["id"],
  540. // pageNo: this.pageNo,
  541. // pagesSize: this.pageSize
  542. // })
  543. // if (this.bianji) {
  544. // getCheckActiveTaskXin({
  545. // id: this.formDataChuangMu["id"]
  546. // }).then(response => { //获取编辑所属部门的数据
  547. // const res = response.data
  548. // res.deptList.map(
  549. // v => { //进入编辑界面以前勾选的所属部门把他放进this.list[0].deptList.中添加一个checkedList
  550. // this.list3.map(listK => {
  551. // if (v.id == listK.id) {
  552. // listK.checkedList3 = [v.id]
  553. // }
  554. // })
  555. // this.checkedList3.push([v.id]) //这句话有问题 传到后端的数据
  556. // })
  557. // });
  558. // }
  559. // });
  560. // },
  561. //========
  562. checkboxChange(i, n) { //输出的是选中的项目id数组
  563. if (i && n.length != 0) {
  564. this.checkedList.push(n)
  565. } else if (i && n.length == 0) {
  566. this.checkedList = this.checkedList.filter(item => item != i)
  567. }
  568. },
  569. checkboxChange2(i, n) {
  570. if (i && n.length != 0) {
  571. this.checkedList2.push(n)
  572. } else if (i && n.length == 0) {
  573. this.checkedList2 = this.checkedList2.filter(item => item != i)
  574. }
  575. },
  576. // 展示检查项的弹出层
  577. showCheckboxShow(pageNo, value = '') {
  578. this.checkboxShow = true
  579. this.getHeightList()
  580. // this.checkedTotal(this.pageNo)
  581. },
  582. // 展示单位选择的弹出层
  583. showSex(pageNo, value = '') {
  584. this.checkboxShow2 = true
  585. },
  586. checkedTotal(pageNo) {
  587. this.pageNo = pageNo
  588. jiase({
  589. inspType: 'dict_inspect_type'
  590. }).then(response => { //检查项数据列表
  591. this.list = response.data
  592. const json = JSON.stringify({
  593. id: this.formDataChuangMu["id"],
  594. // pageNo: this.pageNo,
  595. // pagesSize: this.pageSize
  596. })
  597. if (this.bianji) {
  598. getCheckActiveTaskXin({
  599. id: this.formDataChuangMu["id"]
  600. }).then(response => { //获取编辑主动检查项的数据
  601. const res = response.data
  602. res.inspectList.map(
  603. v => { //进入编辑界面以前勾选的检查项把他放进this.list[0].inspectInfoDOList中添加一个checkedList
  604. this.list.map(i => {
  605. i.inspectInfoDOList.map(listK => {
  606. if (v.id == listK.id) {
  607. listK.checkedList = [v.id]
  608. }
  609. })
  610. })
  611. this.checkedList.push([v.id]) //这句话有问题 传到后端的数据
  612. })
  613. });
  614. }
  615. });
  616. },
  617. //侧边栏导航联动
  618. getHeightList() {
  619. let _this = this;
  620. this.$nextTick(() => {
  621. let selectorQuery = uni.createSelectorQuery();
  622. selectorQuery.selectAll('.nav-left-item').boundingClientRect(rects => {
  623. _this.leftItemHeight = rects[0].height;
  624. _this.navLeftHeight = _this.leftItemHeight * this.list.length;
  625. _this.diff = _this.navLeftHeight - _this.height;
  626. });
  627. selectorQuery.selectAll('.box').boundingClientRect(function(rects) {
  628. let arr = [0];
  629. let top = 0;
  630. if (rects) {
  631. rects.forEach(function(rect) {
  632. top += rect.height;
  633. arr.push(top);
  634. });
  635. };
  636. _this.arr = arr;
  637. }).exec();
  638. })
  639. },
  640. scroll(e) {
  641. let _this = this;
  642. if (this.timeoutId) {
  643. clearTimeout(this.timeoutId);
  644. }
  645. this.timeoutId = setTimeout(function() {
  646. //节流
  647. _this.scrollHeight = e.detail.scrollTop + 1 + _this.height/7;
  648. //+1不要删除,解决最后一项某种情况下翻到底部,左边按钮并不会切换至最后一个
  649. //若想使切换参考线为屏幕顶部请删除 _this.height/2
  650. for (let i = 0; i < _this.arr.length; i++) {
  651. let height1 = _this.arr[i];
  652. let height2 = _this.arr[i + 1];
  653. if (!height2 || (_this.scrollHeight >= height1 && _this.scrollHeight < height2)) {
  654. _this.categoryActive =i;
  655. _this.diff > 0 && (_this.scrollLeftTop = Math.round((_this.categoryActive * _this
  656. .diff) / (this.list.length - 1)));
  657. return false;
  658. }
  659. }
  660. _this.categoryActive = 0;
  661. _this.timeoutId = undefined;
  662. }, 10);
  663. },
  664. categoryClickMain(index, item) {
  665. this.categoryActive = index;
  666. this.scrollTop = this.arr[index]
  667. // this.scrollTop == this.arr[index] ? (this.scrollTop = this.scrollTop + 1) : (this.scrollTop = this.arr[
  668. // index]); //防止两次相等造成点击不触发滚动时间
  669. },
  670. getData(pageNo, value = '') {
  671. // this.loading = true
  672. this.pageNo = pageNo
  673. const form = {
  674. // pageNo: this.pageNo,
  675. // pageSize: this.pageSize,
  676. userId: this.$store.state.user.id
  677. }
  678. addCheckActiveCompany( //获取所属单位JSON.stringify(form)
  679. form
  680. ).then(response => {
  681. // response.data.map((v,index)=>{
  682. // console.log(index,'indexindexindexindex');
  683. // })
  684. // for(let key in response.data){
  685. // key=checkType('backend_org_type',key)
  686. // }
  687. for (let key in response.data) {
  688. response.data[key].unshift(checkType('backend_org_type', key))
  689. }
  690. this.list2 = response.data
  691. const json = JSON.stringify({
  692. id: this.formDataChuangMu["id"],
  693. pageNo: this.pageNo,
  694. pagesSize: this.pageSize
  695. })
  696. if (this.bianji) {
  697. getCheckActiveTaskXin({
  698. id: this.formDataChuangMu["id"]
  699. }).then(response => { //获取编辑主动检查单位的数据
  700. const res = response.data
  701. for (let g in this.list2) {
  702. // g.map(v => { //进入编辑界面以前勾选的检查项把他放进this.list.orgList中添加一个checkedList
  703. this.list2[g].map(i => {
  704. // i.orgDOList.map(listK => {
  705. if (i.id == this.list2[g].id) {
  706. this.list2[g].checkedList2 = [i.id]
  707. }
  708. // })
  709. })
  710. this.checkedList2.push([this.list2[g].id]) //这句话有问题 传到后端的数据
  711. // })
  712. }
  713. });
  714. }
  715. });
  716. },
  717. sureNew() { //确认发布
  718. saveCheckRelease({
  719. id: this.ids
  720. }).then(response => {
  721. if (response.data) {
  722. uni.showToast({
  723. title: `发布成功`
  724. })
  725. setTimeout(() => {
  726. uni.redirectTo({
  727. url: `/pagesA/fire/check_active/index?current=2&type=${this.formDataChuangMu.taskType}`
  728. });
  729. }, 500);
  730. }
  731. })
  732. this.showNew = false
  733. },
  734. cancelNew() { //取消发布--暂存
  735. this.showNew = false
  736. setTimeout(() => {
  737. setTimeout(() => {
  738. uni.redirectTo({
  739. url: `/pagesA/fire/check_active/index?current=3&type=${this.formDataChuangMu.taskType}`
  740. });
  741. }, 500);
  742. }, 0);
  743. },
  744. select(e) {
  745. // 根据所选图片的个数,多次调用上传函数
  746. let promises = [];
  747. for (let i = 0; i < e.tempFilePaths.length; i++) {
  748. const promise = this.uploadFiles(e.tempFilePaths, i);
  749. promises.push(promise);
  750. }
  751. Promise.all(promises).then(result => {});
  752. },
  753. // 上传文件函数
  754. async uploadFiles(tempFilePaths, i) {
  755. this.loading = true
  756. const that = this;
  757. await uni.uploadFile({
  758. url: baseUrl + '/admin-api/infra/file/upload', //后端用于处理图片并返回图片地址及文件的接口
  759. filePath: tempFilePaths[i],
  760. name: 'file',
  761. header: {
  762. Authorization: 'Bearer ' + getAccessToken()
  763. }, //请求token
  764. success: res => {
  765. let data = JSON.parse(res.data);
  766. this.formData.attId[0] = data.data
  767. this.formDataChuangMu.attId = data.data
  768. uni.showToast({
  769. title: '文件上传成功!'
  770. });
  771. that.loading = false
  772. },
  773. fail: () => {
  774. uni.showToast({
  775. icon: 'error',
  776. title: '文件上传失败!'
  777. });
  778. this.loading = false
  779. }
  780. });
  781. },
  782. // 移出图片函数
  783. async deleteFile(e) {
  784. this.formData.attId = [];
  785. // console.log('移除了:');
  786. },
  787. submit(ref) {
  788. this.$refs[ref].validate().then(res => {
  789. this.formDataChuangMu.taskContent = this.formData.taskContent
  790. this.formDataChuangMu.taskName = this.formData.taskName
  791. if (this.bianji) {
  792. editCheckActiveCreate(JSON.stringify(this.formDataChuangMu)).then(response => { //编辑接口
  793. if (response.code == 0) {
  794. uni.showToast({
  795. title: '创建成功'
  796. });
  797. this.showNew = true
  798. this.ids = response.data
  799. } else {
  800. uni.showToast({
  801. title: response.msg
  802. });
  803. }
  804. });
  805. } else {
  806. addCheckActiveCreate(JSON.stringify(this.formDataChuangMu)).then(response => { //修改接口
  807. if (response.code == 0) {
  808. this.showNew = true
  809. this.ids = response.data
  810. } else {
  811. uni.showToast({
  812. title: response.msg
  813. });
  814. }
  815. });
  816. }
  817. }).catch(err => {
  818. uni.$u.toast('校验失败')
  819. })
  820. },
  821. //
  822. // submitError(ref) {
  823. // this.$refs[ref].validate().then(res => {
  824. // console.log('success', res);
  825. // addCheckActiveErrorsubmit(this.formData).then(response => {
  826. // console.log('response.data.msg0,', response.data.msg);
  827. // uni.showLoading({
  828. // title: response.data.msg
  829. // });
  830. // setTimeout(() => {
  831. // uni.hideLoading();
  832. // this.$tab.navigateTo('/pagesA/fire/check_active/index')
  833. // }, 2000);
  834. // });
  835. // }).catch(err => {
  836. // console.log('err', err);
  837. // uni.$u.toast('校验失败')
  838. // })
  839. // },
  840. // 触底的事件
  841. scrolltolower() {
  842. // 判断是否还有下一页数据
  843. if (this.pageNo * this.pageSize >= this.total) return uni.showToast({
  844. title: `数据加载完毕`
  845. })
  846. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  847. if (this.loading) return
  848. this.pageNo += 1
  849. this.showCheckboxShow(this.pageNo)
  850. this.showSex(this.pageNo)
  851. },
  852. },
  853. }
  854. </script>
  855. <style lang="scss" scoped>
  856. page {
  857. height: 100%;
  858. background-color: #f5f7f9;
  859. position: relative;
  860. }
  861. .buttomBorder {
  862. height: 0px;
  863. border: 1px dashed #CBD5E1;
  864. }
  865. /deep/ .uni-section .uni-section-header {
  866. padding: 0px;
  867. }
  868. /deep/ .u-form-item__body {
  869. font-weight: 500;
  870. flex-direction: column !important;
  871. }
  872. /deep/ .u-form-item__body__left__content__label {
  873. width: 144rpx !important;
  874. margin-bottom: 16rpx;
  875. margin-left: 20rpx;
  876. font-size: 30rpx !important;
  877. color: #274647 !important;
  878. }
  879. .arrow-icon {
  880. //主动检查箭头
  881. position: absolute;
  882. right: 14px;
  883. top: 49px;
  884. transform: rotate(90deg);
  885. }
  886. /deep/ .u-input[data-v-fdbb9fe6],
  887. /deep/ .u-input.data-v-fdbb9fe6,
  888. /deep/ .u-input {
  889. background-color: #fff;
  890. }
  891. /deep/.u-button[data-v-3bf2dba7],
  892. /deep/.u-button.data-v-3bf2dba7,
  893. /deep/.u-button {
  894. width: 60% !important;
  895. }
  896. /deep/ .u-form-item__body__right__message {
  897. //校验的文字的位置
  898. margin-left: 10rpx !important;
  899. }
  900. /deep/ .uicon-close {
  901. //关闭按钮背景色
  902. // background-color: rgba(199, 203, 210, .9);
  903. border-radius: 10%;
  904. }
  905. //*号位置
  906. /deep/.u-form-item__body__left__content__required[data-v-5e7216f1],
  907. /deep/.u-form-item__body__left__content__required.data-v-5e7216f1,
  908. /deep/.u-form-item__body__left__content__required {
  909. left: 14rpx !important;
  910. }
  911. // 巡查内容补充的位置
  912. .xuncha {
  913. /deep/.u-form-item__body__left {
  914. width: 220rpx !important;
  915. }
  916. }
  917. .checkbox {
  918. .checkbox-item {
  919. box-sizing: border-box;
  920. padding-top: 40px;
  921. }
  922. }
  923. //侧边联动
  924. .page-body {
  925. display: flex;
  926. background: #fff;
  927. overflow: hidden;
  928. }
  929. .nav {
  930. display: flex;
  931. width: 100%;
  932. }
  933. .nav-left {
  934. width: 25%;
  935. background: #fafafa;
  936. }
  937. .nav-left-item {
  938. padding: 0px 12px;
  939. height: 150rpx;
  940. border-right: solid 1px #f1f1f1;
  941. border-bottom: solid 1px #f1f1f1;
  942. font-size: 30upx;
  943. display: flex;
  944. align-items: center;
  945. justify-content: center;
  946. }
  947. .nav-left-item:last-child {
  948. border-bottom: none;
  949. }
  950. .nav-right {
  951. width: 75%;
  952. }
  953. /deep/.nav-right-item {
  954. width: 100%;
  955. display: flex;
  956. flex-wrap: wrap;
  957. }
  958. /deep/.u-checkbox {
  959. width: 80% !important;
  960. margin-bottom: 30rpx !important;
  961. }
  962. /deep/ .u-checkbox-group {
  963. width: 100%;
  964. // justify-content: flex-end;
  965. }
  966. .box {
  967. display: block;
  968. overflow: hidden;
  969. border-bottom: 20upx solid #f3f3f3;
  970. /* min-height: 100vh; */
  971. /*若您的子分类过少想使得每个子分类占满屏请放开上边注视 */
  972. }
  973. .box:last-child {
  974. border: none;
  975. min-height: 100vh;
  976. }
  977. .u-checkbox-group--row.data-v-3d1b15f2 {
  978. display: flex;
  979. flex-direction: row;
  980. }
  981. .nav-right-item {
  982. margin-top: 20rpx;
  983. float: left;
  984. padding: 11upx;
  985. font-size: 28upx;
  986. background: #fff;
  987. /deep/.u-checkbox__icon-wrap[data-v-532d01c7],
  988. /deep/.u-checkbox__icon-wrap {
  989. //复选框的样式
  990. margin: 0 20rpx;
  991. }
  992. /deep/ uni-view[data-v-3d1b15f2] {
  993. //复选框上线的间距
  994. margin: 20rpx 0 !important;
  995. }
  996. // /deep/ .u-checkbox__icon-wrap--square{
  997. // margin: 20rpx;
  998. // }
  999. .u-checkbox-label--right[data-v-532d01c7],
  1000. .u-checkbox-label--right {
  1001. margin-right: 40rpx;
  1002. }
  1003. }
  1004. .nav-right-item image {
  1005. width: 150upx;
  1006. height: 150upx;
  1007. }
  1008. .active {
  1009. font-weight: 700;
  1010. color: #274647;
  1011. background: #fff;
  1012. border-right: 0;
  1013. }
  1014. ::-webkit-scrollbar {
  1015. /*取消小程序的默认导航条样式*/
  1016. width: 0;
  1017. height: 0;
  1018. color: transparent;
  1019. }
  1020. .selectBtn {
  1021. width: 200rpx;
  1022. margin-left: 0;
  1023. font-size: 30rpx;
  1024. background-color: #4cb2b6;
  1025. }
  1026. /deep/.uni-input-input,
  1027. /deep/.u-input__content__field-wrapper__field.data-v-fdbb9fe6 {
  1028. overflow: hidden;
  1029. -o-text-overflow: ellipsis;
  1030. text-overflow: ellipsis;
  1031. white-space: nowrap;
  1032. display: block;
  1033. }
  1034. /deep/ .u-checkbox uni-text,
  1035. /deep/ .u-checkbox text {
  1036. line-height: 40rpx !important;
  1037. white-space: normal;
  1038. word-break: break-all;
  1039. word-warp: break-word;
  1040. }
  1041. .popup-button {
  1042. width: 75%;
  1043. position: absolute;
  1044. left: 25%;
  1045. bottom: 20rpx;
  1046. z-index: 9999;
  1047. background-color: #fff;
  1048. }
  1049. .zan-cun {
  1050. margin-top: 200rpx;
  1051. }
  1052. .u-page__tag-item {
  1053. width: 90%;
  1054. margin: 30rpx 0;
  1055. margin-left: 5%;
  1056. }
  1057. .box[data-v-524457c8]:last-child,
  1058. .box.data-v-524457c8:last-child,
  1059. .box:last-child {
  1060. padding-bottom: 354rpx;
  1061. }
  1062. </style>