index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="用印人" prop="employeeName">
  5. <el-input v-model="queryParams.employeeName" placeholder="请输入用印人" clearable style="width: 250px"
  6. @keyup.enter.native="handleQuery"/>
  7. </el-form-item>
  8. <el-form-item label="部门" prop="deptId">
  9. <treeselect style="width: 250px" :default-expand-level="1" v-model="queryParams.deptId" :options="deptOptions" :normalizer="normalizer" placeholder="选择部门" />
  10. </el-form-item>
  11. <el-form-item label="职位" prop="postId">
  12. <el-select v-model="queryParams.postId" placeholder="请选择"
  13. style="width: 250px">
  14. <el-option v-for="item in postOptions" :key="item.id" :label="item.name" :value="item.id">
  15. </el-option>
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="手机号" prop="employeePhone">
  19. <el-input v-model="queryParams.employeePhone" placeholder="请输入手机号" clearable style="width: 250px"
  20. @keyup.enter.native="handleQuery"/>
  21. </el-form-item>
  22. <el-form-item label="用印标题" prop="stampTitle">
  23. <el-input v-model="queryParams.stampTitle" placeholder="请输入用印标题" clearable style="width: 250px"
  24. @keyup.enter.native="handleQuery"/>
  25. </el-form-item>
  26. <!-- <el-form-item label="状态" prop="status">
  27. <el-select v-model="queryParams.status" placeholder="状态" clearable style="width: 250px">
  28. <el-option label="已完成" value="0"/>
  29. <el-option label="已作废" value="1"/>
  30. <el-option label="已生效" value="2"/>
  31. </el-select>
  32. </el-form-item> -->
  33. <el-form-item label="数据来源" prop="infoSource">
  34. <el-select v-model="queryParams.infoSource" placeholder="数据来源" clearable style="width: 250px">
  35. <el-option label="流程添加" value="0"/>
  36. <el-option label="手动添加" value="1"/>
  37. </el-select>
  38. </el-form-item>
  39. <el-form-item label="申请时间" prop="createTime">
  40. <el-date-picker v-model="queryParams.createTime" style="width: 250px" value-format="yyyy-MM-dd HH:mm:ss"
  41. type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
  42. :default-time="['00:00:00', '23:59:59']" />
  43. </el-form-item>
  44. <el-form-item>
  45. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  46. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  47. </el-form-item>
  48. </el-form>
  49. <el-row :gutter="10" class="mb8">
  50. <el-col :span="1.5">
  51. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  52. v-hasPermi="['stamp:list:create']">新增</el-button>
  53. </el-col>
  54. <el-col :span="1.5">
  55. <el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
  56. v-hasPermi="['stamp:list:export']">导出</el-button>
  57. </el-col>
  58. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  59. </el-row>
  60. <el-table v-loading="loading" :data="StampList">
  61. <el-table-column label="序号" type="index" width="50"align="center"/>
  62. <el-table-column label="用印人" align="center" prop="employeeName" min-width="100" />
  63. <el-table-column label="部门" align="center" prop="deptName" min-width="100" />
  64. <el-table-column label="职位" align="center" prop="position" min-width="100" />
  65. <el-table-column label="手机号" align="center" prop="employeePhone" min-width="110" />
  66. <el-table-column label="用印标题" align="center" prop="stampTitle" min-width="150" />
  67. <el-table-column label="创建人" align="center" prop="createEmployeeName" min-width="100" />
  68. <!-- <el-table-column label="状态" align="center" prop="status">
  69. <template v-slot="scope">
  70. <span>{{ scope.row.status == 0 ? '已完成' : scope.row.status == 1 ? '已作废' : '已生效'}}</span>
  71. </template>
  72. </el-table-column> -->
  73. <el-table-column label="数据来源" align="center" prop="infoSource">
  74. <template v-slot="scope">
  75. <span>{{ scope.row.infoSource == 0 ? '流程添加' : '手动添加'}}</span>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="创建时间" align="center" prop="createTime" min-width="180">
  79. <template v-slot="scope">
  80. <span>{{ parseTime(scope.row.createTime) }}</span>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" min-width="150">
  84. <template v-slot="scope">
  85. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  86. v-hasPermi="['stamp:list:update']">修改</el-button>
  87. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  88. v-hasPermi="['stamp:list:delete']">删除</el-button>
  89. <el-button size="mini" type="text" icon="el-icon-detail" @click="handleDetail(scope.row)"
  90. >详情</el-button>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  95. @pagination="getList" />
  96. <!-- 添加或修改对话框 -->
  97. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  98. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  99. <el-form-item label="用印人" prop="employeeName">
  100. <el-input v-model="form.employeeName" placeholder='点击选择' readonly @click.native="openSingle"></el-input>
  101. </el-form-item>
  102. <el-form-item label="用印人Id" style="display: none;">
  103. <el-input v-model="form.employeeId" placeholder='用印人Id' disabled></el-input>
  104. </el-form-item>
  105. <el-form-item label="部门">
  106. <el-input v-model="form.deptName" placeholder='部门' disabled></el-input>
  107. </el-form-item>
  108. <el-form-item label="职位">
  109. <el-input v-model="form.position" placeholder='职位' disabled></el-input>
  110. </el-form-item>
  111. <el-form-item label="手机号">
  112. <el-input v-model="form.employeePhone" placeholder='手机号' disabled></el-input>
  113. </el-form-item>
  114. <el-form-item label="用印标题" prop="stampTitle">
  115. <el-input maxlength="20" v-model="form.stampTitle" placeholder='请输入申请的简要标题'></el-input>
  116. </el-form-item>
  117. <el-form-item label="用章类型" prop="stampSealId">
  118. <el-checkbox-group v-model="form.stampSealId">
  119. <el-checkbox v-for="item in oaStampSeal" :label="item.id" :key="item.id">{{item.sealName}}</el-checkbox>
  120. </el-checkbox-group>
  121. </el-form-item>
  122. <el-form-item label="用印事由" prop="reason">
  123. <el-input maxlength="50" show-word-limit type="textarea" v-model="form.reason"
  124. placeholder='请输入用印事由'></el-input>
  125. </el-form-item>
  126. <el-form-item label="附件">
  127. <el-upload :action="fileUrl" :headers="headers" :file-list="files" :on-success="handleFileSuccessCite"
  128. :before-upload="beforeUploadFile" :on-remove="handleRemove">
  129. <el-button size="small" type="primary">点击上传</el-button>
  130. </el-upload>
  131. </el-form-item>
  132. <el-form-item label="备注">
  133. <el-input maxlength="200" rows="4" show-word-limit type="textarea" v-model="form.remarks" placeholder="请输入备注" />
  134. </el-form-item>
  135. </el-form>
  136. <div slot="footer" class="dialog-footer">
  137. <el-button type="primary" @click="submitForm">确 定</el-button>
  138. <el-button @click="cancel">取 消</el-button>
  139. </div>
  140. </el-dialog>
  141. <!-- 详情对话框 -->
  142. <el-dialog :title="title" :visible.sync="openDetail" width="800px" append-to-body>
  143. <div class="widget-wrapper">
  144. <div class="widget-list" v-loading="loading">
  145. <div class="fx-field x-grid-col-12">
  146. <div class="field-label">
  147. <div class="field-name">用印人</div>
  148. </div>
  149. <div class="field-component">
  150. <span :title="form.loginName">{{ form.employeeName }}</span>
  151. </div>
  152. </div>
  153. <div class="fx-field x-grid-col-12">
  154. <div class="field-label">
  155. <div class="field-name">部门</div>
  156. </div>
  157. <div class="field-component">
  158. <span :title="form.deptName">{{ form.deptName }}</span>
  159. </div>
  160. </div>
  161. <div class="fx-field x-grid-col-12">
  162. <div class="field-label">
  163. <div class="field-name">职位</div>
  164. </div>
  165. <div class="field-component">
  166. <span :title="form.position">{{ form.position }}</span>
  167. </div>
  168. </div>
  169. <div class="fx-field x-grid-col-12">
  170. <div class="field-label">
  171. <div class="field-name">手机号</div>
  172. </div>
  173. <div class="field-component">
  174. <span :title="form.employeePhone">{{ form.employeePhone }}</span>
  175. </div>
  176. </div>
  177. <div class="fx-field x-grid-col-12">
  178. <div class="field-label">
  179. <span class="field-required">*</span>
  180. <div class="field-name">用印标题</div>
  181. </div>
  182. <div class="field-component">
  183. <span :title="form.stampTitle">{{ form.stampTitle }}</span>
  184. </div>
  185. </div>
  186. <div class="fx-field x-grid-col-12">
  187. <div class="field-label">
  188. <span class="field-required">*</span>
  189. <div class="field-name">用章类型</div>
  190. </div>
  191. <div class="field-component">
  192. <el-checkbox-group v-model="form.stampSealId">
  193. <el-checkbox v-for="item in oaStampSeal" :label="item.id" :key="item.id" disabled>{{item.sealName}}</el-checkbox>
  194. </el-checkbox-group>
  195. </div>
  196. </div>
  197. <div class="fx-field x-grid-col-12">
  198. <div class="field-label">
  199. <span class="field-required">*</span>
  200. <div class="field-name">用印事由</div>
  201. </div>
  202. <div class="field-component">
  203. <span :title="form.reason">{{ form.reason }}</span>
  204. </div>
  205. </div>
  206. <div class="fx-field x-grid-col-12">
  207. <div class="field-label">
  208. <div class="field-name">附件</div>
  209. </div>
  210. <div class="field-component">
  211. <div v-for="(item, index) in form.fileList" :key="index">
  212. <a :href="item.url" target="_blank" :title="item.name" style="color: #5094d5;">{{ item.name }}</a>
  213. </div>
  214. </div>
  215. </div>
  216. <div class="fx-field x-grid-col-12">
  217. <div class="field-label">
  218. <div class="field-name">备注</div>
  219. </div>
  220. <div class="field-component">
  221. <span :title="form.birthday">{{ form.remarks }}</span>
  222. </div>
  223. </div>
  224. </div>
  225. </div>
  226. </el-dialog>
  227. <PeopleSelect ref="peopleSelect" type="single" :isCheck="true" :open="singlePeopleOpen"
  228. @cancel="singlePeopleOpen = false" @submit="submitSingle"></PeopleSelect>
  229. </div>
  230. </template>
  231. <script>
  232. import { listSimplePosts } from "@/api/system/post";
  233. import { getEmployeeInfo } from "@/api/system/user";
  234. import { listStamp, getStamp, delStamp, addStamp, updateStamp, exportStamp } from "@/api/stamp/list";
  235. import { typeList } from "@/api/oa/stamp"
  236. import Treeselect from "@riophae/vue-treeselect";
  237. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  238. import PeopleSelect from "@/components/PeopleSelect/index.vue";
  239. import { DICT_TYPE } from '@/utils/dict'
  240. import { listDept } from "@/api/system/dept";
  241. import { getBaseHeader } from "@/utils/request";
  242. export default {
  243. name: "SystemStamp",
  244. components: {
  245. PeopleSelect,
  246. Treeselect,
  247. },
  248. data() {
  249. return {
  250. oaStampSeal:[
  251. ],
  252. postOptions:[],
  253. // 部门列表
  254. deptOptions: [], // 部门属性结构
  255. // 遮罩层
  256. loading: true,
  257. // 导出遮罩层
  258. exportLoading: false,
  259. // 显示搜索条件
  260. showSearch: true,
  261. // 总条数
  262. total: 0,
  263. // 表格数据
  264. StampList: [],
  265. // 弹出层标题
  266. title: "",
  267. // 是否显示弹出层
  268. open: false,
  269. openDetail: false,
  270. // 查询参数
  271. queryParams: {
  272. pageNo: 1,
  273. pageSize: 10,
  274. employeeName: undefined,
  275. deptId: undefined,
  276. postId: undefined,
  277. employeePhone: undefined,
  278. stampTitle: undefined,
  279. status: undefined,
  280. infoSource:undefined,
  281. createTime: []
  282. },
  283. // 表单参数
  284. form: {},
  285. // 表单校验
  286. rules: {
  287. employeeName: [
  288. { required: true, message: '请选择', trigger: 'change' },
  289. ],
  290. stampTitle: [
  291. { required: true, message: '请输入申请的简要标题', trigger: 'blur' },
  292. ],
  293. stampSealId: [
  294. { required: true, message: '请选择印章类型', trigger: 'blur' },
  295. ],
  296. reason: [
  297. { required: true, message: '请输入详细描述', trigger: 'blur' }
  298. ],
  299. },
  300. files: [],
  301. // 设置上传的请求头部
  302. headers: getBaseHeader(),
  303. // 上传的地址
  304. fileUrl: process.env.VUE_APP_BASE_API + '/admin-api/infra/file/uploaData',
  305. singlePeopleOpen: false,
  306. };
  307. },
  308. created() {
  309. this.getList();
  310. this.getListDept();
  311. this.getTypeList();
  312. },
  313. methods: {
  314. getEmployee() {
  315. getEmployeeInfo(this.form.employeeId).then(response => {
  316. let employeeInfo = response.data;
  317. this.form.deptName = employeeInfo.deptName;
  318. this.form.position = employeeInfo.position;
  319. this.form.employeePhone = employeeInfo.phone;
  320. });
  321. },
  322. // 类型信息列表
  323. getTypeList(){
  324. typeList().then(
  325. response => {
  326. this.oaStampSeal = response.data;
  327. }
  328. );
  329. },
  330. /** 查询部门列表 */
  331. getListDept() {
  332. listDept().then(response => {
  333. this.deptOptions = this.handleTree(response.data, "id");
  334. });
  335. listSimplePosts().then(response => {
  336. // 处理 postOptions 参数
  337. this.postOptions = [];
  338. this.postOptions.push(...response.data);
  339. });
  340. },
  341. /** 转换部门数据结构 */
  342. normalizer(node) {
  343. if (node.children && !node.children.length) {
  344. delete node.children;
  345. }
  346. return {
  347. id: node.id,
  348. label: node.name,
  349. children: node.children
  350. };
  351. },
  352. //打开选人弹窗
  353. openSingle() {
  354. this.singlePeopleOpen = true;
  355. },
  356. submitSingle(userNamelist, nikeNamelist,userIdList) {
  357. console.log(userNamelist);
  358. this.form.employeeName = nikeNamelist.join();
  359. this.form.employeeId = userIdList.join();
  360. this.getEmployee();
  361. this.singlePeopleOpen = false;
  362. },
  363. /** 查询列表 */
  364. getList() {
  365. this.loading = true;
  366. listStamp(this.queryParams).then(response => {
  367. this.StampList = response.data.list;
  368. this.total = response.data.total;
  369. this.loading = false;
  370. });
  371. },
  372. // 取消按钮
  373. cancel() {
  374. this.open = false;
  375. this.reset();
  376. },
  377. // 表单重置
  378. reset() {
  379. this.files = [],
  380. this.form = {
  381. employeeName: undefined,
  382. deptName: undefined,
  383. position: undefined,
  384. employeePhone: undefined,
  385. stampTitle: undefined,
  386. stampSealId: [],
  387. reason: undefined,
  388. fileIdList: undefined,
  389. remarks: undefined,
  390. };
  391. this.resetForm("form");
  392. },
  393. /** 搜索按钮操作 */
  394. handleQuery() {
  395. this.queryParams.pageNo = 1;
  396. this.getList();
  397. },
  398. /** 重置按钮操作 */
  399. resetQuery() {
  400. this.resetForm("queryForm");
  401. this.handleQuery();
  402. },
  403. /** 新增按钮操作 */
  404. handleAdd() {
  405. this.reset();
  406. this.open = true;
  407. this.title = "添加";
  408. },
  409. handleRemove(file, fileList) {
  410. console.log(file, fileList);
  411. let fileIds = [];
  412. for (let i in fileList) {
  413. let id = fileList[i].response.data.id;
  414. fileIds.push(id);
  415. }
  416. this.form.fileIdList = fileIds;
  417. },
  418. handlePreview(file) {
  419. console.log("file", file);
  420. var link = document.createElement("a"); //定义一个a标签
  421. link.download = file.name; //下载后的文件名称
  422. link.href = file.url; //需要生成一个 URL 来实现下载
  423. link.click(); //模拟在按钮上实现一次鼠标点击
  424. window.URL.revokeObjectURL(link.href);
  425. },
  426. beforeUploadFile(file) {
  427. console.log(file);
  428. const size = file.size / 1024 / 1024;
  429. console.log(size);
  430. if (size > 5) {
  431. this.$message.error("文件大小不能超过5MB!");
  432. return false;
  433. }
  434. },
  435. handleFileSuccessCite(res, file, fileList) {
  436. console.log(file, fileList);
  437. console.log("------", "==========");
  438. console.log("res = ", res);
  439. let fileIds = [];
  440. for (let i in fileList) {
  441. let response = fileList[i].response;
  442. if (response.errno && response.errno != "0") {
  443. this.$message.error("该文件上传失败,已被移除,请重新上传!");
  444. // 上传失败移除该 file 对象
  445. fileList.splice(i, 1);
  446. } else {
  447. let id = fileList[i].response.data.id;
  448. fileIds.push(id);
  449. }
  450. }
  451. this.form.fileIdList = fileIds;
  452. },
  453. /** 修改按钮操作 */
  454. handleUpdate(row) {
  455. this.reset();
  456. const id = row.id
  457. getStamp(id).then(response => {
  458. this.form = response.data;
  459. let files = response.data.fileList;
  460. if (files) {
  461. this.files = [];
  462. for (let i in files) {
  463. let url = files[i].url;
  464. let name = files[i].name;
  465. let id = files[i].id;
  466. this.files.push({
  467. name: name,
  468. url: url,
  469. response: { error: "0", data: { url: url, id: id } },
  470. });
  471. }
  472. }
  473. this.open = true;
  474. this.title = "修改";
  475. });
  476. },
  477. /** 详情按钮操作 */
  478. handleDetail(row) {
  479. this.reset();
  480. const id = row.id
  481. getStamp(id).then(response => {
  482. this.form = response.data;
  483. this.openDetail = true;
  484. this.title = "详情";
  485. });
  486. },
  487. /** 提交按钮 */
  488. submitForm: function () {
  489. console.log(this.form);
  490. this.$refs["form"].validate(valid => {
  491. if (valid) {
  492. if (this.form.id !== undefined) {
  493. updateStamp(this.form).then(response => {
  494. this.$modal.msgSuccess("修改成功");
  495. this.open = false;
  496. this.getList();
  497. });
  498. } else {
  499. addStamp(this.form).then(response => {
  500. this.$modal.msgSuccess("新增成功");
  501. this.open = false;
  502. this.getList();
  503. });
  504. }
  505. }
  506. });
  507. },
  508. /** 删除按钮操作 */
  509. handleDelete(row) {
  510. const ids = row.id;
  511. this.$modal.confirm('是否确认删除数据项?').then(function () {
  512. return delStamp(ids);
  513. }).then(() => {
  514. this.getList();
  515. this.$modal.msgSuccess("删除成功");
  516. }).catch(() => { });
  517. },
  518. /** 导出按钮操作 */
  519. handleExport() {
  520. const queryParams = this.queryParams;
  521. this.$modal.confirm('是否确认导出所有数据项?').then(() => {
  522. this.exportLoading = true;
  523. return exportStamp(queryParams);
  524. }).then(response => {
  525. this.$download.excel(response, '用印数据.xls');
  526. this.exportLoading = false;
  527. }).catch(() => { });
  528. }
  529. }
  530. };
  531. </script>
  532. <style lang="scss" scoped>
  533. .user-avatar {
  534. width: 22px;
  535. height: 22px;
  536. line-height: 19px;
  537. font-size: 12px;
  538. background: #46c26f;
  539. border: 1px solid transparent;
  540. border-radius: 50%;
  541. color: #fff;
  542. display: inline-block;
  543. overflow: hidden;
  544. text-align: center;
  545. vertical-align: middle;
  546. margin-bottom: 2px;
  547. }
  548. .el-tag+.el-tag {
  549. margin-left: 10px;
  550. }
  551. .button-new-tag {
  552. margin-right: 10px;
  553. height: 30px;
  554. line-height: 30px;
  555. padding-top: 0;
  556. padding-bottom: 0;
  557. }
  558. .widget-wrapper>.widget-list {
  559. display: flex;
  560. flex-wrap: wrap;
  561. }
  562. .x-grid-col-6 {
  563. width: 50%;
  564. }
  565. .x-grid-col-12 {
  566. width: 100%;
  567. }
  568. .fx-field {
  569. line-height: 20px;
  570. padding: 7px 12px 12px;
  571. position: relative;
  572. }
  573. .fx-field .field-label {
  574. word-wrap: break-word;
  575. color: #141e31;
  576. display: flex;
  577. font-weight: 600;
  578. line-height: 20px;
  579. padding: 5px 0;
  580. position: relative;
  581. word-break: break-word;
  582. }
  583. .fx-field .field-label .field-required {
  584. color: #eb5050;
  585. margin-left: -6px;
  586. position: relative;
  587. }
  588. .fx-field .field-label .field-name {
  589. overflow: hidden;
  590. }
  591. .field-component {
  592. word-wrap: break-word;
  593. background: #f5f6f8;
  594. border-radius: 2px;
  595. color: #141e31;
  596. font-size: 14px;
  597. line-height: 20px;
  598. min-height: 32px;
  599. padding: 6px 8px;
  600. white-space: pre-wrap;
  601. word-break: break-word;
  602. }
  603. ul {
  604. padding-left: 0px !important;
  605. }
  606. .el-tag+.el-tag {
  607. margin-left: 10px;
  608. }
  609. </style>