index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="序号" prop="serialNumber">
  5. <el-input
  6. v-model="queryParams.serialNumber"
  7. placeholder="请输入序号"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="项目" prop="item">
  14. <el-input
  15. v-model="queryParams.item"
  16. placeholder="请输入项目"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="确认人" prop="confirm">
  23. <el-input
  24. v-model="queryParams.confirm"
  25. placeholder="请输入确认人"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  33. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  34. </el-form-item>
  35. </el-form>
  36. <el-row :gutter="10" class="mb8">
  37. <el-col :span="1.5">
  38. <el-button
  39. type="danger"
  40. icon="el-icon-refresh-left"
  41. size="mini"
  42. v-if="isApprove==2"
  43. :disabled="multiple"
  44. @click="handleTurnDown"
  45. v-hasPermi="['pssr:subcontent:edit']"
  46. >驳回
  47. </el-button>
  48. </el-col>
  49. <el-col :span="1.5">
  50. <el-button
  51. type="warning"
  52. icon="el-icon-download"
  53. size="mini"
  54. @click="handleExport"
  55. v-hasPermi="['pssr:subcontent:export']"
  56. >导出
  57. </el-button>
  58. </el-col>
  59. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  60. </el-row>
  61. <el-table :span-method="mergeMethod" v-loading="loading" :data="subcontentList" @selection-change="handleSelectionChange"
  62. :height="ch" border>
  63. <el-table-column type="selection" width="55" align="center"/>
  64. <el-table-column label="部门" align="center" prop="deptUnit" :show-overflow-tooltip="true" width="80"/>
  65. <el-table-column label="序号" align="center" prop="serialNumber" :show-overflow-tooltip="true" width="80"/>
  66. <el-table-column label="项目" align="center" prop="item" :show-overflow-tooltip="true" width="180"/>
  67. <el-table-column label="开车条件检查内容" align="center" prop="content" :show-overflow-tooltip="true" width="700"/>
  68. <el-table-column label="审批状态" align="center" prop="approveStatus" width="110">
  69. <template slot-scope="scope">
  70. <dict-tag :options="dict.type.pssr_approve_status" :value="scope.row.approveStatus"
  71. :show-type="getTagType(scope.row.approveStatus)"/>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="确认人" align="center" prop="confirmName" :show-overflow-tooltip="true" width="180"/>
  75. <el-table-column label="确认时间" align="center" prop="confirmationDate" width="150">
  76. <template slot-scope="scope">
  77. <span>{{ parseTime(scope.row.confirmationDate, '{y}-{m}-{d}') }}</span>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="备注" align="center" prop="remarks" :show-overflow-tooltip="true" width="180"/>
  81. <el-table-column label="操作" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
  82. <template slot-scope="scope">
  83. <el-button
  84. size="mini"
  85. type="text"
  86. icon="el-icon-document-copy"
  87. @click="gotoSubIndex(scope.row)"
  88. >检查项
  89. </el-button>
  90. </template>
  91. </el-table-column>
  92. </el-table>
  93. <pagination
  94. v-show="total>0"
  95. :total="total"
  96. :page.sync="queryParams.pageNum"
  97. :limit.sync="queryParams.pageSize"
  98. @pagination="getList"
  99. />
  100. <!-- 添加或修改开车条件确认对话框 -->
  101. <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" width="500px" append-to-body>
  102. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  103. <el-form-item label="序号" prop="serialNumber">
  104. <el-input v-model="form.serialNumber" placeholder="请输入序号"/>
  105. </el-form-item>
  106. <el-form-item label="项目" prop="item">
  107. <el-input v-model="form.item" placeholder="请输入项目"/>
  108. </el-form-item>
  109. <el-form-item label="开车条件检查内容">
  110. <editor v-model="form.content" :min-height="192"/>
  111. </el-form-item>
  112. <el-form-item label="确认人" prop="confirm">
  113. <el-input v-model="form.confirm" placeholder="请输入确认人"/>
  114. </el-form-item>
  115. <el-form-item label="备注" prop="remarks">
  116. <el-input v-model="form.remarks" placeholder="请输入备注"/>
  117. </el-form-item>
  118. </el-form>
  119. <div slot="footer" class="dialog-footer">
  120. <el-button type="primary" @click="submitForm">确 定</el-button>
  121. <el-button @click="cancel">取 消</el-button>
  122. </div>
  123. </el-dialog>
  124. <!-- 用户导入对话框 -->
  125. <el-dialog :close-on-click-modal="false" :title="upload.title" :visible.sync="upload.open" width="400px"
  126. append-to-body>
  127. <el-upload
  128. ref="upload"
  129. :limit="1"
  130. accept=".xlsx, .xls"
  131. :headers="upload.headers"
  132. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  133. :disabled="upload.isUploading"
  134. :on-progress="handleFileUploadProgress"
  135. :on-success="handleFileSuccess"
  136. :auto-upload="false"
  137. drag
  138. >
  139. <i class="el-icon-upload"></i>
  140. <div class="el-upload__text">
  141. 将文件拖到此处,或
  142. <em>点击上传</em>
  143. </div>
  144. <div class="el-upload__tip" slot="tip">
  145. <el-checkbox v-model="upload.updateSupport"/>
  146. 是否更新已经存在的用户数据
  147. <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
  148. </div>
  149. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
  150. </el-upload>
  151. <div slot="footer" class="dialog-footer">
  152. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  153. <el-button @click="upload.open = false">取 消</el-button>
  154. </div>
  155. </el-dialog>
  156. </div>
  157. </template>
  158. <script>
  159. import {
  160. addSubcontent,
  161. delSubcontent,
  162. exportSubcontent,
  163. getSubcontent,
  164. handleTurnDownSubcontent,
  165. importTemplate,
  166. listSubcontent,
  167. updateSubcontent,
  168. updateSubcontentBatch,
  169. } from "@/api/pssr/subcontent";
  170. import {treeselect} from "@/api/system/dept";
  171. import {getToken} from "@/utils/auth";
  172. import Treeselect from "@riophae/vue-treeselect";
  173. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  174. import {listUserNoPage} from "@/api/system/user";
  175. export default {
  176. dicts: ['pssr_approve_status'],
  177. name: "Subcontent",
  178. components: {Treeselect},
  179. // components: { Editor },
  180. props: {
  181. aboveallId: {
  182. type: Number,
  183. default: 0
  184. },
  185. isApprove: {
  186. type: Number,
  187. default: 0
  188. },
  189. clientHeight: {
  190. type: Number,
  191. default: 300
  192. },
  193. taskType: {
  194. type: Number,
  195. default: 0
  196. }
  197. },
  198. data() {
  199. return {
  200. ch :this.clientHeight,
  201. userOptions: [],
  202. // 遮罩层
  203. loading: true,
  204. // 选中数组
  205. ids: [],
  206. // 非单个禁用
  207. single: true,
  208. // 非多个禁用
  209. multiple: true,
  210. // 显示搜索条件
  211. showSearch: false,
  212. // 总条数
  213. total: 0,
  214. // 开车条件确认表格数据
  215. subcontentList: [],
  216. // 弹出层标题
  217. title: "",
  218. // 部门树选项
  219. deptOptions: undefined,
  220. // 是否显示弹出层
  221. open: false,
  222. openBatch: false,
  223. // 用户导入参数
  224. upload: {
  225. // 是否显示弹出层(用户导入)
  226. open: false,
  227. // 弹出层标题(用户导入)
  228. title: "",
  229. // 是否禁用上传
  230. isUploading: false,
  231. // 是否更新已经存在的用户数据
  232. updateSupport: 0,
  233. // 设置上传的请求头部
  234. headers: {Authorization: "Bearer " + getToken()},
  235. // 上传的地址
  236. url: process.env.VUE_APP_BASE_API + "/pssr/subcontent/importData"
  237. },
  238. // 查询参数
  239. queryParams: {
  240. pageNum: 1,
  241. pageSize: 50,
  242. approveId: null,
  243. aboveallId: null,
  244. serialNumber: null,
  245. item: null,
  246. content: null,
  247. confirm: null,
  248. confirmationDate: null,
  249. createrCode: null,
  250. createdate: null,
  251. updaterCode: null,
  252. updatedate: null,
  253. deptId: null,
  254. taskType: this.taskType,
  255. remarks: null
  256. },
  257. // 表单参数
  258. form: {},
  259. // 表单校验
  260. rules: {}
  261. };
  262. },
  263. watch: {
  264. // 根据名称筛选部门树
  265. deptName(val) {
  266. this.$refs.tree.filter(val);
  267. }
  268. },
  269. created() {
  270. //设置表格高度对应屏幕高度
  271. this.$nextTick(() => {
  272. this.ch = document.body.clientHeight - 250
  273. })
  274. const id = this.$route.params.aboveallId || this.aboveallId
  275. if (typeof id !== 'undefined') {
  276. this.queryParams.aboveallId = id
  277. }
  278. this.getList();
  279. this.getTreeselect();
  280. listUserNoPage({}).then(res => {
  281. this.userOptions = res.data
  282. });
  283. },
  284. methods: {
  285. handleTurnDown(val) {
  286. this.$prompt('请输入驳回原因', '提示', {
  287. confirmButtonText: '确认驳回',
  288. cancelButtonText: '取消',
  289. }).then(({value}) => {
  290. let data = {
  291. ids: this.ids,
  292. aboveallId: this.aboveallId,
  293. remarks: value
  294. }
  295. handleTurnDownSubcontent(data).then(res => {
  296. this.msgSuccess("驳回成功");
  297. })
  298. }).catch(() => {
  299. this.$message({
  300. type: 'info',
  301. message: '取消驳回'
  302. });
  303. });
  304. },
  305. getTagType(val) {
  306. if (val == 0) {
  307. return ''
  308. } else if (val == 1) {
  309. return 'warning'
  310. } else if (val == 2) {
  311. return 'success'
  312. }
  313. },
  314. gotoSubIndex(row) {
  315. this.$router.push({name: 'Subitem', params: {subId: row.id, serialNumber: row.forShort}});
  316. },
  317. /** 查询开车条件确认列表 */
  318. getList() {
  319. this.loading = true;
  320. listSubcontent(this.queryParams).then(response => {
  321. this.subcontentList = response.rows;
  322. this.total = response.total;
  323. this.loading = false;
  324. });
  325. },
  326. /** 查询部门下拉树结构 */
  327. getTreeselect() {
  328. treeselect().then(response => {
  329. this.deptOptions = response.data;
  330. });
  331. },
  332. // 取消按钮
  333. cancel() {
  334. this.open = false;
  335. this.reset();
  336. },
  337. // 表单重置
  338. reset() {
  339. this.form = {
  340. id: null,
  341. approveId: null,
  342. aboveallId: null,
  343. serialNumber: null,
  344. item: null,
  345. content: null,
  346. confirm: null,
  347. confirmationDate: null,
  348. delFlag: null,
  349. createrCode: null,
  350. createdate: null,
  351. updaterCode: null,
  352. updatedate: null,
  353. deptId: null,
  354. remarks: null
  355. };
  356. this.resetForm("form");
  357. },
  358. /** 搜索按钮操作 */
  359. handleQuery() {
  360. this.queryParams.pageNum = 1;
  361. this.getList();
  362. },
  363. /** 重置按钮操作 */
  364. resetQuery() {
  365. this.resetForm("queryForm");
  366. this.handleQuery();
  367. },
  368. // 多选框选中数据
  369. handleSelectionChange(selection) {
  370. this.ids = selection.map(item => item.id)
  371. this.single = selection.length !== 1
  372. this.multiple = !selection.length
  373. },
  374. /** 新增按钮操作 */
  375. handleAdd() {
  376. this.reset();
  377. this.open = true;
  378. this.title = "添加开车条件确认";
  379. },
  380. /** 修改按钮操作 */
  381. handleUpdate(row) {
  382. this.reset();
  383. const id = row.id || this.ids
  384. getSubcontent(id).then(response => {
  385. this.form = response.data;
  386. this.open = true;
  387. this.title = "修改开车条件确认";
  388. });
  389. },
  390. /** 提交按钮 */
  391. submitForm() {
  392. this.$refs["form"].validate(valid => {
  393. if (valid) {
  394. if (this.form.id != null) {
  395. updateSubcontent(this.form).then(response => {
  396. this.msgSuccess("修改成功");
  397. this.open = false;
  398. this.getList();
  399. });
  400. } else {
  401. addSubcontent(this.form).then(response => {
  402. this.msgSuccess("新增成功");
  403. this.open = false;
  404. this.getList();
  405. });
  406. }
  407. }
  408. });
  409. },
  410. /** 删除按钮操作 */
  411. handleDelete(row) {
  412. const ids = row.id || this.ids;
  413. this.$confirm('是否确认删除?', "警告", {
  414. confirmButtonText: "确定",
  415. cancelButtonText: "取消",
  416. type: "warning"
  417. }).then(function () {
  418. return delSubcontent(ids);
  419. }).then(() => {
  420. this.getList();
  421. this.msgSuccess("删除成功");
  422. })
  423. },
  424. /** 导出按钮操作 */
  425. handleExport() {
  426. const queryParams = this.queryParams;
  427. this.$confirm('是否确认导出所有开车条件确认数据项?', "警告", {
  428. confirmButtonText: "确定",
  429. cancelButtonText: "取消",
  430. type: "warning"
  431. }).then(function () {
  432. return exportSubcontent(queryParams);
  433. }).then(response => {
  434. window.open(process.env.VUE_APP_BASE_API + response.msg);
  435. })
  436. },
  437. /** 导入按钮操作 */
  438. handleImport() {
  439. this.upload.title = "用户导入";
  440. this.upload.open = true;
  441. },
  442. /** 下载模板操作 */
  443. importTemplate() {
  444. importTemplate().then(response => {
  445. this.download(response.msg);
  446. });
  447. },
  448. // 文件上传中处理
  449. handleFileUploadProgress(event, file, fileList) {
  450. this.upload.isUploading = true;
  451. },
  452. // 文件上传成功处理
  453. handleFileSuccess(response, file, fileList) {
  454. this.upload.open = false;
  455. this.upload.isUploading = false;
  456. this.$refs.upload.clearFiles();
  457. this.$alert(response.msg, "导入结果", {dangerouslyUseHTMLString: true});
  458. this.getList();
  459. },
  460. // 提交上传文件
  461. submitFileForm() {
  462. this.$refs.upload.submit();
  463. },
  464. //合并单元格
  465. mergeMethod({row, column, rowIndex, columnIndex}) {
  466. if ([1].includes(columnIndex)) {
  467. const _row = this.setTable(this.subcontentList).merge[rowIndex];
  468. const _col = _row > 0 ? 1 : 0;
  469. return {
  470. rowspan: _row,
  471. colspan: _col
  472. };
  473. }
  474. },
  475. //单元格整理
  476. setTable(tableData) {
  477. let spanArr = [],
  478. concat = 0;
  479. tableData.forEach((item, index) => {
  480. if (index === 0) {
  481. spanArr.push(1);
  482. } else {
  483. if (item.deptUnit === tableData[index - 1].deptUnit) {
  484. //第一列需合并相同内容的判断条件
  485. spanArr[concat] += 1;
  486. spanArr.push(0);
  487. } else {
  488. spanArr.push(1);
  489. concat = index;
  490. }
  491. }
  492. });
  493. return {
  494. merge: spanArr
  495. };
  496. },
  497. }
  498. };
  499. </script>