Sin descripción
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

class2.vue 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957
  1. <template>
  2. <div class="h5-container">
  3. <van-nav-bar title="学习课程管理">
  4. <template #right>
  5. <van-icon
  6. name="add"
  7. size="24"
  8. color="var(--van-nav-bar-icon-color)"
  9. @click="handAdd"
  10. />
  11. <van-popover
  12. v-model:show="showPopover"
  13. :actions="actions"
  14. placement="bottom-end"
  15. @select="onSelect"
  16. >
  17. <template #reference>
  18. <van-icon name="filter-o" size="24px" />
  19. </template>
  20. </van-popover>
  21. </template>
  22. </van-nav-bar>
  23. <van-search v-model="query.name" show-action placeholder="请输入学习任务名称" @search="onRefresh"
  24. @cancel="handdelect" />
  25. <!-- 项目列表 -->
  26. <van-pull-refresh v-model="isRefreshing" success-text="刷新成功" @refresh="onRefresh">
  27. <van-list v-model:loading="isLoading" :finished="isFinished" finished-text="没有更多了" offset="200" @load="onLoad">
  28. <div v-for="(item, idx) in resultData" :key="item.id">
  29. <van-swipe-cell title-style="color: #007aff" style="height: 80px;" :ref="el => getSwipeCellRef(el, idx)">
  30. <template #default>
  31. <div class="swipe-cell-default">
  32. <van-cell style="height: 100%; display: flex; align-items: center;">
  33. <template #title>
  34. <div class="cell-title">
  35. {{ item.projectName }}
  36. </div>
  37. </template>
  38. <template #label>
  39. <div> 培训学时:{{item.trainHours}} ||培训类别:{{ getProjectTypeName(item.projectType)}}</div>
  40. <div style="width: 112px" :class="getStatusClass(item.statusFlag)">
  41. 状态:
  42. <span v-if="item.statusFlag === '1'" style="width: 200px">已完成</span>
  43. <span v-else-if="item.statusFlag != '1'" style="width: 200px">未完成</span>
  44. <span v-else>未知</span>
  45. </div>
  46. </template>
  47. </van-cell>
  48. <div class="swipe-cell-default-icon">
  49. <van-icon v-if="openStatus[idx]" name="arrow-double-left" @click.stop="openSwipe(idx)" />
  50. <van-icon v-else name="arrow-double-right" @click.stop="closeSwipe(idx)" />
  51. </div>
  52. </div>
  53. </template>
  54. <template #right>
  55. <div style="display: flex; align-items: center; justify-content: flex-end; height: 100%;">
  56. <van-button v-if="isAfter(item.toDate)" class="red-rounded-box-wide" text="已结束"/>
  57. <van-button v-else-if="isBefore(item.fromDate)" class="red-rounded-box-wide" text="未开始"/>
  58. <van-button v-else class="submit-button" @click="goaddPeo(item)" text="进入小节"/>
  59. </div>
  60. </template>
  61. </van-swipe-cell>
  62. </div>
  63. </van-list>
  64. </van-pull-refresh>
  65. <!-- 删除确认弹窗 -->
  66. <van-dialog v-model:show="deleteDialogVisible" show-cancel-button @confirm="confirmDelete">
  67. <template #title>
  68. <div>删除确认</div>
  69. </template>
  70. <div style="padding: 30px;">确定要删除该项目吗?</div>
  71. </van-dialog>
  72. </div>
  73. </template>
  74. <script setup>
  75. import { ref, reactive, onMounted, getCurrentInstance, nextTick, toRaw } from 'vue';
  76. import { Dialog, showDialog, showSuccessToast, showToast, Toast } from 'vant';
  77. const { proxy } = getCurrentInstance();
  78. // 将字符串转为 Date 对象进行比较
  79. const parseDate = (str) => {
  80. if (!str) return null;
  81. // 支持 "YYYY-MM-DD HH:mm:ss" 或 ISO 格式
  82. return new Date(str);
  83. };
  84. // 当前时间是否在 fromDate 之前(未开始)
  85. const isBefore = (fromDateStr) => {
  86. const now = new Date();
  87. const fromDate = parseDate(fromDateStr);
  88. return fromDate && now < fromDate;
  89. };
  90. // 当前时间是否在 toDate 之后(已结束)
  91. const isAfter = (dateStr) => {
  92. if (!dateStr) return false;
  93. const now = new Date();
  94. const today = new Date(now.getFullYear(), now.getMonth(), now.getDate()); // 今天 00:00:00
  95. const [y, m, d] = dateStr.split('-').map(Number);
  96. const deadline = new Date(y, m - 1, d); // 截止日 00:00:00
  97. return today > deadline;
  98. };
  99. const getProjectTypeName = (code) => {
  100. const map = {
  101. 'Gbm': '安全管理',
  102. 'Jja': '生产安全技术',
  103. 'Jjb': '消防安全技术',
  104. 'Jjc': '安全保卫技术',
  105. 'Jjd': '特种作业安全技术',
  106. };
  107. return map[code] || '未知类型';
  108. }
  109. const onClickLeft = () => {
  110. history.back();
  111. };
  112. const headers = ref({
  113. token: localStorage.getItem('token'),
  114. userId: localStorage.getItem('userId'),
  115. dept: JSON.parse(localStorage.getItem('dept'))[0].deptCode
  116. });
  117. const switchIconState = (idx) => {
  118. openStatus.value[idx] = !openStatus.value[idx]
  119. openStatus.value = new Array(resultData.value.length).fill(true);
  120. }
  121. // const onClickRight = () =>{
  122. // searchShow.value = !searchShow.value;
  123. // }
  124. const searchShow = ref(false);
  125. /**
  126. 时间
  127. */
  128. // 当前年份
  129. const currentYear = new Date().getFullYear();
  130. // 生成年份:往前3年,往后1年 → 共5年
  131. const yearRange = Array.from({ length: 5 }, (_, i) => currentYear - 3 + i);
  132. // 构造 actions(符合 van-popover 要求)
  133. const actions = yearRange.map(year => ({
  134. text: `${year}年`
  135. }));
  136. // 默认选中的年份(用于请求)
  137. const selectedYear = ref(currentYear);
  138. // 控制 popover 显示(可选,你用了 v-model:show 就够了)
  139. const showPopover = ref(false);
  140. // 选择回调
  141. const onSelect = (action, index) => {
  142. query.value.year = yearRange[index];
  143. // 👇 触发刷新(带上 selectedYear)
  144. console.log(selectedYear.value);
  145. resetAndRefresh();
  146. };
  147. const query = ref({
  148. year: currentYear, // ← 默认就是今年
  149. name: '',
  150. });
  151. // 重置并刷新(你已有类似逻辑)
  152. const resetAndRefresh = () => {
  153. isFinished.value = false;
  154. isLoading.value = false;
  155. resultData.value = [];
  156. onRefresh();
  157. };
  158. function formatDate(date, format) {
  159. const year = date.getFullYear();
  160. const month = date.getMonth() + 1;
  161. const day = date.getDate();
  162. const hours = date.getHours();
  163. const minutes = date.getMinutes();
  164. const seconds = date.getSeconds();
  165. return format
  166. .replace('yyyy', year)
  167. .replace('MM', month.toString().padStart(2, '0'))
  168. .replace('dd', day.toString().padStart(2, '0'))
  169. .replace('HH', hours.toString().padStart(2, '0'))
  170. .replace('mm', minutes.toString().padStart(2, '0'))
  171. .replace('ss', seconds.toString().padStart(2, '0'));
  172. }
  173. const tableData = ref([]);
  174. const selectedRows = ref([]);
  175. const dialogVisibleLook = ref(false);
  176. const deleteDialogVisible = ref(false);
  177. const currentDeleteItem = ref([]);
  178. const dialogVisible = ref(false);
  179. const dialogVisibleFile = ref(false);
  180. const date = ref(null);
  181. const kz = ref(true);
  182. import { useRouter } from 'vue-router';
  183. const router = useRouter();
  184. const handAdd = () => {
  185. router.push({ path: "/checkList",
  186. query: {
  187. mark:-1
  188. } });
  189. };
  190. const goaddPeo = (item) => {
  191. router.push({
  192. path: '/sectionList',
  193. query: {
  194. data: JSON.stringify(item)
  195. }
  196. })
  197. }
  198. const edits = (row) => {
  199. kz.value = true;
  200. form.value = { ...row };
  201. router.push({ path: "/checkList",
  202. query: {
  203. mark:1,
  204. data:JSON.stringify(form.value)
  205. } });
  206. };
  207. // 定义表单数据
  208. const form = ref({
  209. hdPicId: '',
  210. hdId: '',
  211. hdType: '',
  212. discoveryTime: '',
  213. hdSubtype: '',
  214. discoverer: '',
  215. discovererOther: '',
  216. hdDescription: '',
  217. hdLevel: '',
  218. bz: '',
  219. hdLocation: '',
  220. picBefore: '',
  221. equipmentId: '',
  222. hdmanageLevel: '',
  223. handlingProcesses: '',
  224. companyId: '',
  225. repairLeader: '',
  226. repairOther: '',
  227. repairSuggest: '',
  228. repairDdl: '',
  229. repairDept: '',
  230. acceptLeader: '',
  231. acceptOther: '',
  232. picAfter: '',
  233. picTemp: '',
  234. repairDescription: '',
  235. discovererDept: '',
  236. discovererDeptCode: '',
  237. hdLocationCode: '',
  238. hdLocationName: '',
  239. status: '',
  240. hdSelect: '正常登记',
  241. id: ''
  242. });
  243. const resetForma = () => {
  244. form.value = {
  245. hdPicId: '',
  246. hdId: '',
  247. hdType: '',
  248. discoveryTime: '',
  249. hdSubtype: '',
  250. discoverer: '',
  251. discovererOther: '',
  252. hdDescription: '',
  253. hdLevel: '',
  254. bz: '',
  255. hdLocation: '',
  256. picBefore: '',
  257. equipmentId: '',
  258. hdmanageLevel: '',
  259. handlingProcesses: '',
  260. companyId: '',
  261. repairLeader: '',
  262. repairOther: '',
  263. repairSuggest: '',
  264. repairDdl: '',
  265. repairDept: '',
  266. acceptLeader: '',
  267. acceptOther: '',
  268. picAfter: '',
  269. picTemp: '',
  270. repairDescription: '',
  271. status: '',
  272. discovererDept: '',
  273. discovererDeptCode: '',
  274. hdLocationCode: '',
  275. hdLocationName: '',
  276. hdSelect: '正常登记',
  277. id: ''
  278. };
  279. };
  280. const isRefreshing = ref(false);
  281. const isLoading = ref(false);
  282. const isFinished = ref(false);
  283. const currentPage = ref(1);
  284. const pageSize = ref(10);
  285. const totalRows = ref(0);
  286. const resultData = ref([]);
  287. const dept=localStorage.getItem("dept")[0].deptCode;
  288. const getTableData = async () => {
  289. query.value.addDeptCode=dept
  290. const url = 'sgsafe/Class/queryClassUserSignboard';
  291. const param = {
  292. page: currentPage.value,
  293. rows: pageSize.value,
  294. params: JSON.stringify(query.value)
  295. };
  296. const response = await proxy.$axios.get(url, param);
  297. if (response.data.code === 0) {
  298. tableData.value = response.data.data.records;
  299. totalRows.value = response.data.data.total;
  300. } else {
  301. showToast({
  302. type: 'error',
  303. message: '操作失败!' + response.data.msg
  304. });
  305. }
  306. };
  307. const ruleIds = ref([]);
  308. const getRuleId = () => {
  309. var url = '/sgsafe/ExamHead/getCheckRuleId'
  310. var param = {}
  311. proxy.$axios.get(url, param).then(response => {
  312. if (response.data.code == '0') {
  313. ruleIds.value = response.data.data
  314. } else {
  315. console.log("1111111");
  316. }
  317. })
  318. console.log('ruleIds', ruleIds)
  319. }
  320. const onRefresh = () => {
  321. basicReset();
  322. onLoad();
  323. };
  324. const onLoad = async () => {
  325. if (isRefreshing.value) {
  326. resultData.value = [];
  327. currentPage.value = 1;
  328. isRefreshing.value = false;
  329. }
  330. try {
  331. await getTableData();
  332. await getRuleId()
  333. if (pageSize.value * currentPage.value < totalRows.value) {
  334. resultData.value = [...resultData.value, ...tableData.value];
  335. openStatus.value = new Array(resultData.value.length).fill(true);
  336. currentPage.value++;
  337. } else {
  338. resultData.value = [...resultData.value, ...tableData.value];
  339. openStatus.value = new Array(resultData.value.length).fill(true);
  340. isFinished.value = true;
  341. }
  342. } catch (error) {
  343. console.log(error);
  344. isFinished.value = true;
  345. } finally {
  346. isLoading.value = false;
  347. }
  348. };
  349. /* 通用方法: 重置list数据 */
  350. const basicReset = () => {
  351. isFinished.value = false;
  352. isLoading.value = true;
  353. currentPage.value = 1;
  354. resultData.value = [];
  355. };
  356. /*onMounted(() => {
  357. handleSearch();
  358. });
  359. const handleSearch = () => {
  360. /!* currentPage.value = 1;
  361. isFinished.value = false;
  362. tableData.value = [];*!/
  363. basicReset()
  364. onLoad()
  365. };*/
  366. const handdelect = () => {
  367. query.value.checkName = '';
  368. onRefresh()
  369. };
  370. const handleDetailLook = (row) => {
  371. form.value = { ...row };
  372. proxy.$router.push({
  373. name: 'taiZhang_detail',
  374. query: {
  375. form: form.value.id
  376. }
  377. });
  378. // dialogVisibleLook.value = true;
  379. };
  380. const deleteData=ref({})
  381. const handleDelete = (item) => {
  382. deleteData.value=item
  383. deleteData.value.cancelFlag='1'
  384. var url = '/sgsafe/EduCheckMaster/save';
  385. var param = {
  386. json: JSON.stringify(item)
  387. };
  388. proxy.$axios.post(url, param).then(response => {
  389. if (response.data.code == '0') {
  390. showSuccessToast("删除成功")
  391. onRefresh();
  392. } else {
  393. }
  394. })
  395. };
  396. const confirmDelete = () => {
  397. for (let item of currentDeleteItem.value) {
  398. if (item.addId !== headers.value.userId) {
  399. showToast({
  400. type: 'warning',
  401. message: '只能删除自己添加的数据!'
  402. });
  403. return;
  404. }
  405. }
  406. if (currentDeleteItem.value[0].status !== '0' && currentDeleteItem.value[0].hdSelect !== '下发隐患'
  407. && currentDeleteItem.value[0].hdSelect !== '即查即改') {
  408. showToast({
  409. type: 'fail',
  410. message: '只有尚未提交流程的记录或回到起点的流程经过作废后才可以删除!'
  411. });
  412. return;
  413. }
  414. if (currentDeleteItem.value[0].status !== '2' && currentDeleteItem.value[0].hdSelect === '下发隐患'
  415. && currentDeleteItem.value[0].hdSelect !== '即查即改') {
  416. showToast({
  417. type: 'fail',
  418. message: '只有尚未提交流程的记录或回到起点的流程经过作废后才可以删除!'
  419. });
  420. return;
  421. }
  422. var url = 'sgsafe/Hiddendanger/remove';
  423. var param = {
  424. params: JSON.stringify({ ...currentDeleteItem.value.map(x => x.id) })
  425. };
  426. proxy.$axios.get(url, param).then(response => {
  427. if (response.data.code == 0) {
  428. showToast({
  429. type: 'success',
  430. message: '删除成功'
  431. });
  432. onRefresh();
  433. } else {
  434. showToast({
  435. type: 'fail',
  436. message: '操作失败!' + response.data.msg
  437. });
  438. }
  439. });
  440. };
  441. const resetForm = () => {
  442. form.value = {
  443. projectName: '',
  444. projectLeader: '',
  445. phone: '',
  446. dept: ''
  447. };
  448. };
  449. const baocun = () => {
  450. nextTick(() => {
  451. if (form.value.hdSelect === '正常登记') {
  452. form.value.status = '0';
  453. } else if (form.value.hdSelect === '下发隐患') {
  454. form.value.status = '2';
  455. } else {
  456. form.value.status = '-1';
  457. }
  458. });
  459. // 原有保存逻辑保持不变
  460. var url = 'sgsafe/Hiddendanger/save';
  461. var param = {
  462. json: JSON.stringify(form.value)
  463. };
  464. proxy.$axios.post(url, param).then(response => {
  465. if (response.data.code == '0') {
  466. showSuccessToast('保存成功!');
  467. getTableData();
  468. orJsons();
  469. // clearDeptUsers()
  470. } else {
  471. showToast({
  472. type: 'fail',
  473. message: '操作失败!' + response.data.msg
  474. });
  475. }
  476. });
  477. };
  478. //处理人员code
  479. const repairLL = ref('');
  480. const repairOO = ref('');
  481. const acceptLL = ref('');
  482. const orJsons = () => {
  483. // console.log('forms',form.value)
  484. if (form.value.hdSelect === '正常登记') {
  485. nextTick(() => {
  486. nextTick(() => {
  487. repairLL.value = qq('repairLL', form.value.discoverer);//隐患发现人
  488. nextTick(() => {
  489. repairOO.value = qq('repairOO', form.value.discovererOther);//其他隐患发现人
  490. nextTick(() => {
  491. acceptLL.value = qq('acceptLL', form.value.discoverer);//隐患销号人
  492. });
  493. });
  494. });
  495. // acceptOO.value = qq('acceptOO', form.value.acceptOther)
  496. });
  497. } else {
  498. // console.log('noiajdoifjpoewjfopjp')
  499. nextTick(() => {
  500. nextTick(() => {
  501. repairLL.value = qq('repairLL', form.value.acceptLeader);//隐患发现人
  502. nextTick(() => {
  503. repairOO.value = qq('repairOO', form.value.acceptOther);//其他隐患发现人
  504. nextTick(() => {
  505. acceptLL.value = qq('acceptLL', form.value.discoverer);//隐患销号人
  506. });
  507. });
  508. });
  509. // acceptOO.value = qq('acceptOO', form.value.acceptOther)
  510. });
  511. }
  512. };
  513. const jsons = ref({});
  514. const qq = (a, val) => {
  515. let aa = '';
  516. var url = 'sgsafe/Hiddendanger/qqId';
  517. var param = {
  518. params: val
  519. };
  520. proxy.$axios.post(url, param).then(response => {
  521. if (response.data.code == 0) {
  522. aa = response.data.data;
  523. switch (a) {
  524. case 'repairLL':
  525. repairLL.value = response.data.data;
  526. // console.log('repairLL',repairLL.value);
  527. break;
  528. case 'repairOO':
  529. repairOO.value = response.data.data;
  530. // console.log('repairOO',repairLL.value);
  531. break;
  532. case 'acceptLL':
  533. acceptLL.value = response.data.data;
  534. // console.log('acceptLL',repairLL.value);
  535. break;
  536. default:
  537. break;
  538. }
  539. jsons.value = {
  540. hdConfirm: repairLL.value,
  541. hdConfirmO: repairOO.value,
  542. hdCancel: acceptLL.value
  543. };
  544. // 处理函数
  545. function processValue(value) {
  546. // 将逗号替换为分号
  547. const replacedValue = value.replace(/,/g, ';');
  548. // 分割值
  549. const parts = replacedValue.split(';');
  550. // 每个部分前加上 U_
  551. const processedParts = parts.map(part => `U_${part.trim()}`);
  552. // 重新组合
  553. return processedParts.join(';');
  554. }
  555. // 处理整个对象
  556. const processedData = {};
  557. for (const key in jsons.value) {
  558. if (jsons.value.hasOwnProperty(key)) {
  559. processedData[key] = processValue(jsons.value[key]);
  560. }
  561. }
  562. console.log('对象', toRaw(processedData));
  563. let b = {
  564. acceptL: processedData.hdConfirm,
  565. acceptO: processedData.hdConfirmO,
  566. id: form.value.id
  567. };
  568. if (form.value.hdSelect === '即查即改') {
  569. b = {
  570. hdFxr: processedData.hdCancel,
  571. id: form.value.id
  572. };
  573. }
  574. if (form.value.hdSelect === '正常登记') {
  575. b = {
  576. // hdConfirm: processedData.hdConfirm,
  577. // hdConfirmO: processedData.hdConfirmO,
  578. id: form.value.id
  579. };
  580. }
  581. const aaa = JSON.stringify(toRaw(b));
  582. sessionStorage.setItem('variables', aaa);
  583. console.log('aaa', aaa);
  584. } else {
  585. showToast({
  586. type: 'fail',
  587. message: '操作失败!' + response.data.msg
  588. });
  589. }
  590. });
  591. return aa;
  592. };
  593. const reback = () => {
  594. // 返回逻辑
  595. };
  596. const deleteRow = (row) => {
  597. selectedRows.value = [row];
  598. handleDelete(row);
  599. };
  600. const deleteRowa = (row) => {
  601. deleteRow(row);
  602. };
  603. const bm = (val) => {
  604. // 部门选择逻辑
  605. };
  606. //提交审批流程
  607. import { workflowSubmit, workflowCancel } from '@/tools/workflow.js';
  608. const flowId = ref('');
  609. flowId.value = 'hazardManagementFlowId';
  610. const handleSubmit2 = (val, idx) => {
  611. openStatus.value[idx] = !openStatus.value[idx]
  612. openStatus.value = new Array(resultData.value.length).fill(true);
  613. console.log('提交');
  614. console.log('selectedRows', selectedRows.value);
  615. let row = val;
  616. form.value = { ...row }
  617. form.value.workCreate = headers.value.dept;
  618. let b = {
  619. id: form.value.id,
  620. }
  621. const aaa = JSON.stringify(toRaw(b))
  622. sessionStorage.setItem('variables', aaa)
  623. if (form.value.hdSelect === '正常登记') {
  624. flowId.value = 'hazardManagementFlowId'
  625. } else if (form.value.hdSelect === '下发隐患') {
  626. flowId.value = 'hazardImmediatelyCM'
  627. form.value.status = '2'
  628. } else {
  629. flowId.value = 'hazardImmediatelyCMUpdate'
  630. form.value.status = '-1'
  631. }
  632. console.log('----');
  633. console.log(flowId.value);
  634. console.log(sessionStorage.getItem('variables'));
  635. console.log(row.workId);
  636. console.log(row.trackId);
  637. let titles = '隐患排查治理'
  638. showDialog({
  639. title: '提示',
  640. message: '确定提交审批?',
  641. showCancelButton: true,
  642. confirmButtonText: '确定',
  643. type: 'warning',
  644. cancelButtonText: '取消'
  645. }
  646. ).then(() => {
  647. return workflowSubmit(
  648. flowId.value,
  649. '隐患排查治理',
  650. '初始化提交',
  651. // JSON.stringify({}),
  652. sessionStorage.getItem('variables'),
  653. row.workId,
  654. row.trackId);
  655. }).then((result) => {
  656. if (result.status === 'success') {
  657. // 将结果返回的workId和trackId保存
  658. var url = 'sgsafe/Hiddendanger/saveProcessInfo';
  659. console.log('id', result, row.id);
  660. var process = {
  661. 'id': form.value.id,
  662. 'workId': result.workId,
  663. 'trackId': result.trackId
  664. };
  665. var param = {
  666. json: JSON.stringify(process)
  667. };
  668. proxy.$axios.post(url, param).then(response => {
  669. if (response.data.code === 0) {
  670. form.value = response.data.data;
  671. console.log('我要进来啦保存成功');
  672. showToast({
  673. type: 'success',
  674. message: '提交审批成功'
  675. });
  676. onRefresh()
  677. }
  678. });
  679. } else {
  680. showToast({
  681. type: 'error',
  682. message: '提交审批失败,' + result.msg
  683. });
  684. }
  685. }).catch(() => {
  686. showToast({
  687. type: 'info',
  688. message: '已取消提交'
  689. });
  690. });
  691. };
  692. const getStatusClass = (status) => {
  693. switch (status) {
  694. case '1':
  695. return 'status-rectifying';
  696. default:
  697. return 'status-closed';
  698. }
  699. };
  700. /**
  701. * 按钮实现swipe-cell滑动
  702. */
  703. const openStatus = ref([])
  704. const swipeCellRefs = ref([])
  705. const getSwipeCellRef = (el, index) => {
  706. if (el) {
  707. swipeCellRefs.value[index] = el;
  708. }
  709. }
  710. const openSwipe = (idx) => {
  711. openStatus.value = new Array(resultData.value.length).fill(true);
  712. if (idx >= 0 && idx < swipeCellRefs.value.length) {
  713. openStatus.value[idx] = false
  714. swipeCellRefs.value[idx].open('right')
  715. }
  716. document.addEventListener('click', handleDocumentClick)
  717. }
  718. /**
  719. * 当点击滑动单元格时,开始监听点击事件
  720. */
  721. const handleDocumentClick = (event) => {
  722. openStatus.value = new Array(resultData.value.length).fill(true);
  723. }
  724. const closeSwipe = (idx) => {
  725. if (idx >= 0 && idx < swipeCellRefs.value.length) {
  726. openStatus.value[idx] = true
  727. swipeCellRefs.value[idx].close()
  728. }
  729. }
  730. </script>
  731. <style scoped>
  732. .h5-container {
  733. width: 100%;
  734. padding: 5px;
  735. box-sizing: border-box;
  736. }
  737. .status-pending {
  738. background-color: #fff3cd;
  739. color: #856404;
  740. padding: 2px 4px;
  741. border-radius: 4px;
  742. }
  743. .status-registered {
  744. background-color: #d1ecf1;
  745. color: #0c5460;
  746. padding: 2px 4px;
  747. border-radius: 4px;
  748. }
  749. .status-analyzing {
  750. background-color: #fff8e1;
  751. color: #ff8f00;
  752. padding: 2px 4px;
  753. border-radius: 4px;
  754. }
  755. .status-rectifying {
  756. background-color: #e8f5e9;
  757. color: #2e7d32;
  758. padding: 2px 4px;
  759. border-radius: 4px;
  760. }
  761. .status-accepting {
  762. background-color: #e3f2fd;
  763. color: #1565c0;
  764. padding: 2px 4px;
  765. border-radius: 4px;
  766. }
  767. .status-closed {
  768. background-color: #f8bbd0;
  769. color: #b71c1c;
  770. padding: 2px 4px;
  771. border-radius: 4px;
  772. }
  773. .status-finished {
  774. background-color: #e8eaf6;
  775. color: #311b92;
  776. padding: 2px 4px;
  777. border-radius: 4px;
  778. }
  779. .status-unknown {
  780. background-color: #efebe9;
  781. color: #424242;
  782. padding: 2px 4px;
  783. border-radius: 4px;
  784. }
  785. .cell-title {
  786. display: -webkit-box;
  787. /* 旧版弹性盒子模型 */
  788. -webkit-box-orient: vertical;
  789. /* 内容垂直排列 */
  790. -webkit-line-clamp: 2;
  791. /* 限制显示行数 */
  792. overflow: hidden;
  793. /* 超出隐藏 */
  794. text-overflow: ellipsis;
  795. /* 省略号 */
  796. line-height: 1.5;
  797. /* 可选:设置行高 */
  798. max-height: calc(1.5em * 2);
  799. /* 可选:根据行高限制最大高度 */
  800. font-size: 16px;
  801. font-weight: bold;
  802. color: #333;
  803. /* 字号 */
  804. }
  805. .swipe-cell-default {
  806. display: flex;
  807. background-color: #ffffff;
  808. justify-content: center;
  809. align-items: center;
  810. }
  811. .swipe-cell-default-icon {
  812. width: 60px;
  813. display: flex;
  814. justify-content: center;
  815. }
  816. .delete-button {
  817. height: 100%;
  818. border: none;
  819. color: #ff0000;
  820. background-image: url('@/assets/img/del.png');
  821. background-size: auto 100%;
  822. background-repeat: no-repeat;
  823. }
  824. .red-rounded-box-wide {
  825. width: 80px; /* 可容纳3个字 */
  826. height: 36px; /* 高度适中 */
  827. border: 2px solid red;
  828. border-radius: 18px; /* 圆角 = 高度 / 2 → 完美胶囊形 */
  829. display: flex;
  830. align-items: center;
  831. justify-content: center;
  832. font-size: 14px;
  833. color: #ee0631;
  834. background-color: transparent;
  835. box-sizing: border-box;
  836. }
  837. .submit-button {
  838. height: 100%;
  839. border: none;
  840. color: #07c160;
  841. background-image: url('@/assets/img/sub.png');
  842. background-size: auto 100%;
  843. background-repeat: no-repeat;
  844. }
  845. .subsuccess {
  846. height: 100%;
  847. border: none;
  848. color: #07c160;
  849. background-image: url('@/assets/img/sub1.png');
  850. background-size: auto 100%;
  851. background-repeat: no-repeat;
  852. }
  853. </style>