add_check.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137
  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="100">
  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. console.log(option, 'mmmmmmmmm');
  354. this.formDataChuangMu.taskType = option.type
  355. if (option.id) {
  356. this.bianji = true
  357. const ids = parseInt(option.id)
  358. const json = JSON.stringify({
  359. id: ids,
  360. // pageNo: this.pageNo,
  361. // pagesSize: this.pageSize
  362. })
  363. getCheckActiveTaskXin({
  364. id: ids
  365. }).then(response => { //获取编辑主动检查的数据
  366. console.log(response, 'responseresponse');
  367. const res = response.data
  368. this.formData.taskName = res.taskInfo.taskName
  369. this.formData.taskContent = res.taskInfo.taskContent
  370. this.formData.attId[0] = res.taskInfo.attId ? res.taskInfo.attId : ''
  371. this.formDataChuangMu.attId = res.taskInfo.attId ? res.taskInfo.attId : ''
  372. if (res.orgList && res.orgList.length != 0) {
  373. let item = []
  374. res.orgList.map(v => { //单位
  375. this.formDataChuangMu.orgId.push(v.id)
  376. item.push(v.orgName)
  377. })
  378. this.formData.orgId = item.join(',')
  379. }
  380. if (res.inspectList.length != 0) {
  381. let arr = []
  382. res.inspectList.map(v => { //项目
  383. this.formDataChuangMu.inspectIds.push(v.id)
  384. arr.push(v.inspName)
  385. })
  386. this.formData.inspectIds = arr.join(',')
  387. }
  388. // if (res.deptList.length != 0) {
  389. // this.formData.deptId = '已选择部门'
  390. // res.deptList.map(v => { //部门
  391. // this.formDataChuangMu.deptId.push(v.id)
  392. // })
  393. // }
  394. });
  395. this.formDataChuangMu["id"] = ids
  396. }
  397. },
  398. onReady() {
  399. // this.checkedTotal3(this.pageNo) 部门
  400. this.checkedTotal(this.pageNo)
  401. this.getData(this.pageNo)
  402. this.height = uni.getSystemInfoSync().windowHeight - this.tabBarHeight
  403. // 设置自定义表单校验规则,必须在节点渲染完毕后执行
  404. this.$refs.customForm.setRules(this.customRules)
  405. },
  406. methods: {
  407. closeImage() {
  408. this.formData.attId = []
  409. this.formDataChuangMu.attId = ''
  410. this.$forceUpdate()
  411. },
  412. //查看已上传附件
  413. viewSee(val) {
  414. downSee(val)
  415. },
  416. //上传文件
  417. selectBtn() {
  418. this.$refs.files.upload()
  419. },
  420. // 隐藏键盘
  421. hideKeyboard() {
  422. uni.hideKeyboard()
  423. },
  424. // 生成隐患弹出层 //暂存为草稿箱弹出层
  425. cancel() {
  426. this.show = false;
  427. },
  428. confirm() {
  429. setTimeout(() => {
  430. // 0.5秒后自动关闭
  431. this.show = false;
  432. }, 500)
  433. },
  434. //popup检查项确定
  435. checkboxConfirm() {
  436. this.checkboxShow = false
  437. let arr = []
  438. this.checkedList.map(v => {
  439. v.map(i => {
  440. arr.push(i)
  441. })
  442. })
  443. this.formDataChuangMu.inspectIds = [...new Set(arr)]
  444. let items = []
  445. if (this.checkedList.length != 0) {
  446. this.list.map(i => {
  447. i.inspectInfoDOList.map(k => {
  448. this.formDataChuangMu.inspectIds.map(j => {
  449. if (k.id == j) {
  450. items.push(k.inspName)
  451. }
  452. })
  453. })
  454. })
  455. this.formData.inspectIds = items.join(',')
  456. } else {
  457. this.formData.inspectIds = ''
  458. }
  459. },
  460. //popup取消
  461. checkboxCancel() {
  462. this.checkboxShow = false
  463. this.checkedList = []
  464. this.formData.inspectIds = ''
  465. },
  466. //popup检查单位确定============
  467. checkboxConfirm2() {
  468. this.checkboxShow2 = false
  469. let arr = []
  470. console.log(this.checkedList2, 'this.checkedList2');
  471. this.checkedList2.map(v => {
  472. v.map(i => {
  473. arr.push(i)
  474. })
  475. })
  476. this.formDataChuangMu.orgId = [...new Set(arr)]
  477. let items = []
  478. if (this.checkedList2.length != 0) {
  479. for (let v in this.list2) {
  480. this.list2[v].map(i => {
  481. // i.map(k => {
  482. this.formDataChuangMu.orgId.map(j => {
  483. if (i.dwid == j) {
  484. items.push(i.orgName)
  485. }
  486. })
  487. // })
  488. })
  489. }
  490. this.formData.orgId = items.join(',')
  491. } else {
  492. this.formData.orgId = ''
  493. }
  494. },
  495. //popup取消
  496. checkboxCancel2() {
  497. this.checkboxShow2 = false
  498. this.checkedList2 = []
  499. this.formData.orgId = ''
  500. },
  501. //========
  502. // //popup检查部门确定============
  503. // checkboxConfirm3() {
  504. // this.checkboxShow3 = false
  505. // this.checkedList3.map(v => {
  506. // v.map(i => {
  507. // this.formDataChuangMu.deptId.push(i)
  508. // })
  509. // })
  510. // if (this.checkedList3.length != 0) {
  511. // this.formData.deptId = '已选择部门'
  512. // }else{
  513. // this.formData.deptId =''
  514. // }
  515. // },
  516. // //popup取消
  517. // checkboxCancel3() {
  518. // this.checkboxShow3 = false
  519. // this.checkedList3 = []
  520. // this.formData.deptId =''
  521. // },
  522. // checkboxChange3(i, n) {
  523. // if (i && n.length != 0) {
  524. // this.checkedList3.push(n)
  525. // } else if (i && n.length == 0) {
  526. // this.checkedList3 = this.checkedList3.filter(item => item != i)
  527. // }
  528. // console.log(this.checkedList3, 'this.checkedList3');
  529. // },
  530. // // 展示部门选择的弹出层
  531. // showSex3(pageNo, value = '') {
  532. // this.checkboxShow3 = true
  533. // },
  534. // checkedTotal3(pageNo) { //部门
  535. // this.loading = true
  536. // this.pageNo = pageNo
  537. // addCheckActiveDepartment({}).then(response => { //所属部门数据列表
  538. // console.log(response, 'response部门');
  539. // this.list3 = response.data
  540. // console.log(this.list3, 'this.list3');
  541. // const json = JSON.stringify({
  542. // id: this.formDataChuangMu["id"],
  543. // pageNo: this.pageNo,
  544. // pagesSize: this.pageSize
  545. // })
  546. // if (this.bianji) {
  547. // getCheckActiveTaskXin({
  548. // id: this.formDataChuangMu["id"]
  549. // }).then(response => { //获取编辑所属部门的数据
  550. // const res = response.data
  551. // res.deptList.map(
  552. // v => { //进入编辑界面以前勾选的所属部门把他放进this.list[0].deptList.中添加一个checkedList
  553. // this.list3.map(listK => {
  554. // if (v.id == listK.id) {
  555. // listK.checkedList3 = [v.id]
  556. // }
  557. // })
  558. // this.checkedList3.push([v.id]) //这句话有问题 传到后端的数据
  559. // })
  560. // });
  561. // }
  562. // });
  563. // },
  564. //========
  565. checkboxChange(i, n) { //输出的是选中的项目id数组
  566. if (i && n.length != 0) {
  567. this.checkedList.push(n)
  568. } else if (i && n.length == 0) {
  569. this.checkedList = this.checkedList.filter(item => item != i)
  570. }
  571. },
  572. checkboxChange2(i, n) {
  573. if (i && n.length != 0) {
  574. this.checkedList2.push(n)
  575. } else if (i && n.length == 0) {
  576. this.checkedList2 = this.checkedList2.filter(item => item != i)
  577. }
  578. },
  579. // 展示检查项的弹出层
  580. showCheckboxShow(pageNo, value = '') {
  581. this.checkboxShow = true
  582. this.getHeightList()
  583. // this.checkedTotal(this.pageNo)
  584. },
  585. // 展示单位选择的弹出层
  586. showSex(pageNo, value = '') {
  587. this.checkboxShow2 = true
  588. },
  589. checkedTotal(pageNo) {
  590. this.pageNo = pageNo
  591. jiase({
  592. inspType: 'dict_inspect_type'
  593. }).then(response => { //检查项数据列表
  594. this.list = response.data
  595. const json = JSON.stringify({
  596. id: this.formDataChuangMu["id"],
  597. // pageNo: this.pageNo,
  598. // pagesSize: this.pageSize
  599. })
  600. if (this.bianji) {
  601. getCheckActiveTaskXin({
  602. id: this.formDataChuangMu["id"]
  603. }).then(response => { //获取编辑主动检查项的数据
  604. const res = response.data
  605. res.inspectList.map(
  606. v => { //进入编辑界面以前勾选的检查项把他放进this.list[0].inspectInfoDOList中添加一个checkedList
  607. this.list.map(i => {
  608. i.inspectInfoDOList.map(listK => {
  609. if (v.id == listK.id) {
  610. listK.checkedList = [v.id]
  611. }
  612. })
  613. })
  614. this.checkedList.push([v.id]) //这句话有问题 传到后端的数据
  615. })
  616. });
  617. }
  618. });
  619. },
  620. //侧边栏导航联动
  621. getHeightList() {
  622. let _this = this;
  623. this.$nextTick(() => {
  624. let selectorQuery = uni.createSelectorQuery();
  625. selectorQuery.selectAll('.nav-left-item').boundingClientRect(rects => {
  626. _this.leftItemHeight = rects[0].height;
  627. _this.navLeftHeight = _this.leftItemHeight * this.list.length;
  628. _this.diff = _this.navLeftHeight - _this.height;
  629. });
  630. selectorQuery.selectAll('.box').boundingClientRect(function(rects) {
  631. let arr = [0];
  632. let top = 0;
  633. if (rects) {
  634. rects.forEach(function(rect) {
  635. top += rect.height;
  636. arr.push(top);
  637. });
  638. };
  639. _this.arr = arr;
  640. }).exec();
  641. })
  642. },
  643. scroll(e) {
  644. let _this = this;
  645. if (this.timeoutId) {
  646. clearTimeout(this.timeoutId);
  647. }
  648. this.timeoutId = setTimeout(function() {
  649. //节流
  650. _this.scrollHeight = e.detail.scrollTop + 1 + _this.height/7;
  651. //+1不要删除,解决最后一项某种情况下翻到底部,左边按钮并不会切换至最后一个
  652. //若想使切换参考线为屏幕顶部请删除 _this.height/2
  653. for (let i = 0; i < _this.arr.length; i++) {
  654. let height1 = _this.arr[i];
  655. let height2 = _this.arr[i + 1];
  656. if (!height2 || (_this.scrollHeight >= height1 && _this.scrollHeight < height2)) {
  657. _this.categoryActive =i;
  658. _this.diff > 0 && (_this.scrollLeftTop = Math.round((_this.categoryActive * _this
  659. .diff) / (this.list.length - 1)));
  660. return false;
  661. }
  662. }
  663. _this.categoryActive = 0;
  664. _this.timeoutId = undefined;
  665. }, 10);
  666. },
  667. categoryClickMain(index, item) {
  668. this.categoryActive = index;
  669. this.scrollTop = this.arr[index]
  670. // this.scrollTop == this.arr[index] ? (this.scrollTop = this.scrollTop + 1) : (this.scrollTop = this.arr[
  671. // index]); //防止两次相等造成点击不触发滚动时间
  672. },
  673. getData(pageNo, value = '') {
  674. // this.loading = true
  675. this.pageNo = pageNo
  676. const form = {
  677. // pageNo: this.pageNo,
  678. // pageSize: this.pageSize,
  679. userId: this.$store.state.user.id
  680. }
  681. addCheckActiveCompany( //获取所属单位JSON.stringify(form)
  682. form
  683. ).then(response => {
  684. // response.data.map((v,index)=>{
  685. // console.log(index,'indexindexindexindex');
  686. // })
  687. // for(let key in response.data){
  688. // key=checkType('backend_org_type',key)
  689. // }
  690. for (let key in response.data) {
  691. response.data[key].unshift(checkType('backend_org_type', key))
  692. }
  693. this.list2 = response.data
  694. const json = JSON.stringify({
  695. id: this.formDataChuangMu["id"],
  696. pageNo: this.pageNo,
  697. pagesSize: this.pageSize
  698. })
  699. if (this.bianji) {
  700. getCheckActiveTaskXin({
  701. id: this.formDataChuangMu["id"]
  702. }).then(response => { //获取编辑主动检查单位的数据
  703. console.log(response, 'ressss');
  704. const res = response.data
  705. for (let g in this.list2) {
  706. // g.map(v => { //进入编辑界面以前勾选的检查项把他放进this.list.orgList中添加一个checkedList
  707. this.list2[g].map(i => {
  708. // i.orgDOList.map(listK => {
  709. if (i.id == this.list2[g].id) {
  710. console.log(i, '[i.id][i.id][i.id]', this.list2);
  711. this.list2[g].checkedList2 = [i.id]
  712. }
  713. // })
  714. })
  715. this.checkedList2.push([this.list2[g].id]) //这句话有问题 传到后端的数据
  716. // })
  717. }
  718. });
  719. }
  720. });
  721. },
  722. sureNew() { //确认发布
  723. saveCheckRelease({
  724. id: this.ids
  725. }).then(response => {
  726. if (response.data) {
  727. uni.showToast({
  728. title: `发布成功`
  729. })
  730. setTimeout(() => {
  731. uni.redirectTo({
  732. url: `/pagesA/fire/check_active/index?current=2&type=${this.formDataChuangMu.taskType}`
  733. });
  734. }, 500);
  735. }
  736. })
  737. this.showNew = false
  738. },
  739. cancelNew() { //取消发布--暂存
  740. this.showNew = false
  741. console.log(this.formDataChuangMu.taskType, 'this.formDataChuangMu.taskType');
  742. setTimeout(() => {
  743. setTimeout(() => {
  744. uni.redirectTo({
  745. url: `/pagesA/fire/check_active/index?current=3&type=${this.formDataChuangMu.taskType}`
  746. });
  747. }, 500);
  748. }, 0);
  749. },
  750. select(e) {
  751. // 根据所选图片的个数,多次调用上传函数
  752. let promises = [];
  753. for (let i = 0; i < e.tempFilePaths.length; i++) {
  754. const promise = this.uploadFiles(e.tempFilePaths, i);
  755. promises.push(promise);
  756. }
  757. Promise.all(promises).then(result => {});
  758. },
  759. // 上传文件函数
  760. async uploadFiles(tempFilePaths, i) {
  761. this.loading = true
  762. const that = this;
  763. await uni.uploadFile({
  764. url: baseUrl + '/admin-api/infra/file/upload', //后端用于处理图片并返回图片地址及文件的接口
  765. filePath: tempFilePaths[i],
  766. name: 'file',
  767. header: {
  768. Authorization: 'Bearer ' + getAccessToken()
  769. }, //请求token
  770. success: res => {
  771. let data = JSON.parse(res.data);
  772. this.formData.attId[0] = data.data
  773. this.formDataChuangMu.attId = data.data
  774. uni.showToast({
  775. title: '文件上传成功!'
  776. });
  777. that.loading = false
  778. },
  779. fail: () => {
  780. uni.showToast({
  781. icon: 'error',
  782. title: '文件上传失败!'
  783. });
  784. this.loading = false
  785. }
  786. });
  787. },
  788. // 移出图片函数
  789. async deleteFile(e) {
  790. this.formData.attId = [];
  791. // console.log('移除了:');
  792. },
  793. submit(ref) {
  794. this.$refs[ref].validate().then(res => {
  795. this.formDataChuangMu.taskContent = this.formData.taskContent
  796. this.formDataChuangMu.taskName = this.formData.taskName
  797. if (this.bianji) {
  798. editCheckActiveCreate(JSON.stringify(this.formDataChuangMu)).then(response => { //编辑接口
  799. if (response.code == 0) {
  800. uni.showToast({
  801. title: '创建成功'
  802. });
  803. this.showNew = true
  804. this.ids = response.data
  805. } else {
  806. uni.showToast({
  807. title: response.msg
  808. });
  809. }
  810. });
  811. } else {
  812. addCheckActiveCreate(JSON.stringify(this.formDataChuangMu)).then(response => { //修改接口
  813. if (response.code == 0) {
  814. this.showNew = true
  815. this.ids = response.data
  816. } else {
  817. uni.showToast({
  818. title: response.msg
  819. });
  820. }
  821. });
  822. }
  823. }).catch(err => {
  824. uni.$u.toast('校验失败')
  825. })
  826. },
  827. //
  828. // submitError(ref) {
  829. // this.$refs[ref].validate().then(res => {
  830. // console.log('success', res);
  831. // addCheckActiveErrorsubmit(this.formData).then(response => {
  832. // console.log('response.data.msg0,', response.data.msg);
  833. // uni.showLoading({
  834. // title: response.data.msg
  835. // });
  836. // setTimeout(() => {
  837. // uni.hideLoading();
  838. // this.$tab.navigateTo('/pagesA/fire/check_active/index')
  839. // }, 2000);
  840. // });
  841. // }).catch(err => {
  842. // console.log('err', err);
  843. // uni.$u.toast('校验失败')
  844. // })
  845. // },
  846. // 触底的事件
  847. scrolltolower() {
  848. // 判断是否还有下一页数据
  849. if (this.pageNo * this.pageSize >= this.total) return uni.showToast({
  850. title: `数据加载完毕`
  851. })
  852. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  853. if (this.loading) return
  854. this.pageNo += 1
  855. this.showCheckboxShow(this.pageNo)
  856. this.showSex(this.pageNo)
  857. },
  858. },
  859. }
  860. </script>
  861. <style lang="scss" scoped>
  862. page {
  863. height: 100%;
  864. background-color: #f5f7f9;
  865. position: relative;
  866. }
  867. .buttomBorder {
  868. height: 0px;
  869. border: 1px dashed #CBD5E1;
  870. }
  871. /deep/ .uni-section .uni-section-header {
  872. padding: 0px;
  873. }
  874. /deep/ .u-form-item__body {
  875. font-weight: 500;
  876. flex-direction: column !important;
  877. }
  878. /deep/ .u-form-item__body__left__content__label {
  879. width: 144rpx !important;
  880. margin-bottom: 16rpx;
  881. margin-left: 20rpx;
  882. font-size: 30rpx !important;
  883. color: #274647 !important;
  884. }
  885. .arrow-icon {
  886. //主动检查箭头
  887. position: absolute;
  888. right: 14px;
  889. top: 49px;
  890. transform: rotate(90deg);
  891. }
  892. /deep/ .u-input[data-v-fdbb9fe6],
  893. /deep/ .u-input.data-v-fdbb9fe6,
  894. /deep/ .u-input {
  895. background-color: #fff;
  896. }
  897. /deep/.u-button[data-v-3bf2dba7],
  898. /deep/.u-button.data-v-3bf2dba7,
  899. /deep/.u-button {
  900. width: 60% !important;
  901. }
  902. /deep/ .u-form-item__body__right__message {
  903. //校验的文字的位置
  904. margin-left: 10rpx !important;
  905. }
  906. /deep/ .uicon-close {
  907. //关闭按钮背景色
  908. // background-color: rgba(199, 203, 210, .9);
  909. border-radius: 10%;
  910. }
  911. //*号位置
  912. /deep/.u-form-item__body__left__content__required[data-v-5e7216f1],
  913. /deep/.u-form-item__body__left__content__required.data-v-5e7216f1,
  914. /deep/.u-form-item__body__left__content__required {
  915. left: 14rpx !important;
  916. }
  917. // 巡查内容补充的位置
  918. .xuncha {
  919. /deep/.u-form-item__body__left {
  920. width: 220rpx !important;
  921. }
  922. }
  923. .checkbox {
  924. .checkbox-item {
  925. box-sizing: border-box;
  926. padding-top: 40px;
  927. }
  928. }
  929. //侧边联动
  930. .page-body {
  931. display: flex;
  932. background: #fff;
  933. overflow: hidden;
  934. }
  935. .nav {
  936. display: flex;
  937. width: 100%;
  938. }
  939. .nav-left {
  940. width: 25%;
  941. background: #fafafa;
  942. }
  943. .nav-left-item {
  944. padding: 0px 12px;
  945. height: 150rpx;
  946. border-right: solid 1px #f1f1f1;
  947. border-bottom: solid 1px #f1f1f1;
  948. font-size: 30upx;
  949. display: flex;
  950. align-items: center;
  951. justify-content: center;
  952. }
  953. .nav-left-item:last-child {
  954. border-bottom: none;
  955. }
  956. .nav-right {
  957. width: 75%;
  958. }
  959. /deep/.nav-right-item {
  960. width: 100%;
  961. display: flex;
  962. flex-wrap: wrap;
  963. }
  964. /deep/.u-checkbox {
  965. width: 80% !important;
  966. margin-bottom: 30rpx !important;
  967. }
  968. /deep/ .u-checkbox-group {
  969. width: 100%;
  970. // justify-content: flex-end;
  971. }
  972. .box {
  973. display: block;
  974. overflow: hidden;
  975. border-bottom: 20upx solid #f3f3f3;
  976. /* min-height: 100vh; */
  977. /*若您的子分类过少想使得每个子分类占满屏请放开上边注视 */
  978. }
  979. .box:last-child {
  980. border: none;
  981. min-height: 100vh;
  982. }
  983. .u-checkbox-group--row.data-v-3d1b15f2 {
  984. display: flex;
  985. flex-direction: row;
  986. }
  987. .nav-right-item {
  988. margin-top: 20rpx;
  989. float: left;
  990. padding: 11upx;
  991. font-size: 28upx;
  992. background: #fff;
  993. /deep/.u-checkbox__icon-wrap[data-v-532d01c7],
  994. /deep/.u-checkbox__icon-wrap {
  995. //复选框的样式
  996. margin: 0 20rpx;
  997. }
  998. /deep/ uni-view[data-v-3d1b15f2] {
  999. //复选框上线的间距
  1000. margin: 20rpx 0 !important;
  1001. }
  1002. // /deep/ .u-checkbox__icon-wrap--square{
  1003. // margin: 20rpx;
  1004. // }
  1005. .u-checkbox-label--right[data-v-532d01c7],
  1006. .u-checkbox-label--right {
  1007. margin-right: 40rpx;
  1008. }
  1009. }
  1010. .nav-right-item image {
  1011. width: 150upx;
  1012. height: 150upx;
  1013. }
  1014. .active {
  1015. font-weight: 700;
  1016. color: #274647;
  1017. background: #fff;
  1018. border-right: 0;
  1019. }
  1020. ::-webkit-scrollbar {
  1021. /*取消小程序的默认导航条样式*/
  1022. width: 0;
  1023. height: 0;
  1024. color: transparent;
  1025. }
  1026. .selectBtn {
  1027. width: 200rpx;
  1028. margin-left: 0;
  1029. font-size: 30rpx;
  1030. background-color: #4cb2b6;
  1031. }
  1032. /deep/.uni-input-input,
  1033. /deep/.u-input__content__field-wrapper__field.data-v-fdbb9fe6 {
  1034. overflow: hidden;
  1035. -o-text-overflow: ellipsis;
  1036. text-overflow: ellipsis;
  1037. white-space: nowrap;
  1038. display: block;
  1039. }
  1040. /deep/ .u-checkbox uni-text,
  1041. /deep/ .u-checkbox text {
  1042. line-height: 40rpx !important;
  1043. white-space: normal;
  1044. word-break: break-all;
  1045. word-warp: break-word;
  1046. }
  1047. .popup-button {
  1048. width: 75%;
  1049. position: absolute;
  1050. left: 25%;
  1051. bottom: 20rpx;
  1052. z-index: 9999;
  1053. background-color: #fff;
  1054. }
  1055. .zan-cun {
  1056. margin-top: 200rpx;
  1057. }
  1058. .u-page__tag-item {
  1059. width: 90%;
  1060. margin: 30rpx 0;
  1061. margin-left: 5%;
  1062. }
  1063. .box[data-v-524457c8]:last-child,
  1064. .box.data-v-524457c8:last-child,
  1065. .box:last-child {
  1066. padding-bottom: 354rpx;
  1067. }
  1068. </style>