taskList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. <template>
  2. <div class="app-container">
  3. <el-row>
  4. <el-col :span="24">
  5. <!-- 现在什么筛选条件也没有 -->
  6. <el-button style="float: right">导出报表N/A</el-button>
  7. <el-button @click="openInsertDialog" style="float: right; margin-right: 15px">添加任务</el-button>
  8. </el-col>
  9. </el-row>
  10. <!-- 列表区域 -->
  11. <el-table :data="task" style="width: 100%" v-loading="loading">
  12. <el-table-column type="index" width="40"></el-table-column>
  13. <el-table-column prop="name" label="任务名称"></el-table-column>
  14. <el-table-column prop="code" label="任务编码" width="120"></el-table-column>
  15. <el-table-column label="任务类型" width="80">
  16. <template slot-scope="scope">{{info[scope.$index].tagName}}</template>
  17. </el-table-column>
  18. <el-table-column label="发起人" width="80">
  19. <template slot-scope="scope">{{info[scope.$index].publisherName}}</template>
  20. </el-table-column>
  21. <el-table-column prop="indate" label="发起时间" width="100"></el-table-column>
  22. <el-table-column prop="planTime" label="计划时间" width="100"></el-table-column>
  23. <el-table-column label="接收人" width="80">
  24. <template slot-scope="scope">{{info[scope.$index].recipientName}}</template>
  25. </el-table-column>
  26. <el-table-column label="参与人">
  27. <template slot-scope="scope">{{info[scope.$index].participant.join("、")}}</template>
  28. </el-table-column>
  29. <el-table-column prop="workLoad" label="工作量" width="80"></el-table-column>
  30. <el-table-column prop="payee" label="收款方" width="80"></el-table-column>
  31. <el-table-column prop="payer" label="付款方" width="80"></el-table-column>
  32. <el-table-column prop="fee" label="费用" width="80"></el-table-column>
  33. <el-table-column label="状态" width="80">
  34. <template slot-scope="scope">
  35. <span v-if="scope.row.state == 0">待派发</span>
  36. <span v-else-if="scope.row.state == 1">已派发</span>
  37. <span v-else-if="scope.row.state == 2">已接收</span>
  38. <span v-else-if="scope.row.state == 3">待审核</span>
  39. <span v-else-if="scope.row.state == 4">未通过</span>
  40. <span v-else-if="scope.row.state == 5">已完成</span>
  41. <span v-else-if="scope.row.state == 6">已延期</span>
  42. <span v-else-if="scope.row.state == 7">已失效</span>
  43. <span v-else-if="scope.row.state == 8">已删除</span>
  44. <span v-else>不明</span>
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="操作" width="180" fixed="right">
  48. <template slot-scope="scope">
  49. <el-button type="primary" @click="toDetail(scope.row.id)">详情</el-button>
  50. <el-button v-if="scope.row.state == 0" @click="openUpdateDialog(scope.$index)">编辑</el-button>
  51. </template>
  52. </el-table-column>
  53. </el-table>
  54. <!-- 页码区域 -->
  55. <el-pagination
  56. @size-change="handleSizeChange"
  57. @current-change="handleCurrentChange"
  58. :current-page="pageIndex"
  59. :page-sizes="[20, 50, 100]"
  60. :page-size="20"
  61. layout="total, sizes, prev, pager, next, jumper"
  62. :total="total"
  63. background
  64. style="float: right"
  65. ></el-pagination>
  66. <!-- 添加和修改任务的dialog -->
  67. <el-dialog title="任务" :visible.sync="taskFormVisible" width="600px">
  68. <el-form ref="form1" :model="taskForm" :rules="rules1" label-width="110px">
  69. <el-form-item label="任务名称" prop="name">
  70. <el-input v-model="taskForm.name" placeholder="请输入任务名称" clearable></el-input>
  71. </el-form-item>
  72. <el-form-item label="任务编码" prop="code">
  73. <el-input v-model="taskForm.code" placeholder="请输入任务编码" clearable></el-input>
  74. </el-form-item>
  75. <el-form-item label="任务类型" prop="tagId">
  76. <!-- 标签 -->
  77. <el-tag
  78. class="tag"
  79. v-for="tag in tags"
  80. :key="tag.id"
  81. :type="taskForm.tagId == tag.id? '': 'info'"
  82. @click="chooseTag(tag.id)"
  83. :closable="tag.id>7"
  84. @close="handleClose(tag.id)"
  85. style="cursor: pointer;"
  86. >{{tag.name}}</el-tag>
  87. <!-- 添加和删除标签的地方 -->
  88. <el-input
  89. class="input-new-tag"
  90. v-if="newTagVisible"
  91. v-model="newTagValue"
  92. ref="saveTagInput"
  93. size="small"
  94. style="width:80px"
  95. @keyup.enter.native="handleInputConfirm"
  96. @blur="newTagVisible=false"
  97. ></el-input>
  98. <el-button v-else class="button-new-tag" size="small" @click="showInput">新建分类</el-button>
  99. </el-form-item>
  100. <el-form-item label="计划时间" prop="planTime">
  101. <el-date-picker
  102. v-model="taskForm.planTime"
  103. type="date"
  104. format="yyyy 年 MM 月 dd 日"
  105. value-format="yyyy-MM-dd"
  106. placeholder="请选择计划时间"
  107. style="width: 100%"
  108. ></el-date-picker>
  109. </el-form-item>
  110. <el-form-item label="工作量" prop="workload">
  111. <el-input v-model="taskForm.workload" placeholder="请输入工作量" clearable></el-input>
  112. </el-form-item>
  113. <el-form-item label="接收人" prop="recipientId">
  114. <el-select
  115. v-model="taskForm.recipientId"
  116. filterable
  117. placeholder="请输入接收人"
  118. style="width: 100%"
  119. >
  120. <el-option v-for="item in user" :key="item.id" :label="item.name" :value="item.id"></el-option>
  121. </el-select>
  122. </el-form-item>
  123. <el-form-item label="参与人" prop="participantIds">
  124. <el-select
  125. v-model="taskForm.participantIds"
  126. multiple
  127. filterable
  128. clearable
  129. placeholder="请输入参与人"
  130. style="width: 100%"
  131. >
  132. <el-option v-for="item in user" :key="item.id" :label="item.name" :value="item.id"></el-option>
  133. </el-select>
  134. </el-form-item>
  135. <el-form-item label="收款方" prop="payee">
  136. <el-input v-model="taskForm.payee" placeholder="请输入收款方" clearable></el-input>
  137. </el-form-item>
  138. <el-form-item label="付款方" prop="payer">
  139. <el-input v-model="taskForm.payer" placeholder="请输入付款方" clearable></el-input>
  140. </el-form-item>
  141. <el-form-item label="费用" prop="fee">
  142. <el-input v-model="taskForm.fee" placeholder="请输入费用" clearable></el-input>
  143. </el-form-item>
  144. <el-form-item label="任务内容" prop="content">
  145. <el-input v-model="taskForm.content" placeholder="请输入任务内容" clearable></el-input>
  146. </el-form-item>
  147. </el-form>
  148. <span slot="footer" class="dialog-footer">
  149. <el-button @click="taskFormVisible = false">取消</el-button>
  150. <el-button type="primary" @click="submit">提交</el-button>
  151. </span>
  152. </el-dialog>
  153. </div>
  154. </template>
  155. <script>
  156. import store from '@/store'
  157. import request from "@/utils/request";
  158. export default {
  159. data() {
  160. return {
  161. task: [],
  162. info: [],
  163. taskForm: {
  164. id: null,
  165. name: null,
  166. code: null,
  167. tagId: null,
  168. planTime: null,
  169. workload: null,
  170. publishId: null,
  171. recipientId: null,
  172. participantIds: null,
  173. payee: null,
  174. payer: null,
  175. fee: null,
  176. content: null,
  177. state: null,
  178. delayTime: null
  179. },
  180. tags: [],
  181. user: [],
  182. taskFormVisible: false,
  183. newTagVisible: false,
  184. newTagValue: "",
  185. loading: false,
  186. //分页相关
  187. pageIndex: 1,
  188. pageSize: 20,
  189. total: 0,
  190. rules1: {
  191. name: [{ required: true, message: "请输入名称", trigger: "blur" }],
  192. code: [{ required: true, message: "请输入编码", trigger: "blur" }],
  193. tagId: [{ required: true, message: "请选择类型", trigger: "blur" }],
  194. planTime: [
  195. { required: true, message: "请选择计划时间", trigger: "blur" }
  196. ],
  197. workload: [
  198. { required: true, message: "请输入工作量", trigger: "blur" }
  199. ],
  200. recipientId: [
  201. { required: true, message: "请选择接收人", trigger: "blur" }
  202. ],
  203. payee: [{ required: true, message: "请输入收款方", trigger: "blur" }],
  204. payer: [{ required: true, message: "请输入付款方", trigger: "blur" }],
  205. fee: [{ required: true, message: "请输入费用", trigger: "blur" }],
  206. content: [
  207. { required: true, message: "请输入任务内容", trigger: "blur" }
  208. ]
  209. }
  210. };
  211. },
  212. methods: {
  213. //获取记录
  214. getTask() {
  215. this.loading = true;
  216. request({
  217. url: "/task/getTaskListByPage",
  218. method: "post",
  219. params: {
  220. pageIndex: this.pageIndex,
  221. pageSize: this.pageSize
  222. }
  223. })
  224. .then(response => {
  225. this.task = response.data.page.records;
  226. this.total = response.data.page.total;
  227. this.info = response.data.other;
  228. this.loading = false;
  229. })
  230. .catch(error => {
  231. this.loading = false;
  232. });
  233. },
  234. //提交创建和更新
  235. submit() {
  236. this.$refs.form1.validate(valid => {
  237. if (valid) {
  238. this.loading = true;
  239. var form = new FormData();
  240. form.append("name", this.taskForm.name);
  241. form.append("code", this.taskForm.code);
  242. form.append("planTime", this.taskForm.planTime);
  243. form.append("workLoad", this.taskForm.workload);
  244. form.append("payer", this.taskForm.payer);
  245. form.append("payee", this.taskForm.payee);
  246. form.append("fee", this.taskForm.fee);
  247. form.append("tagId", this.taskForm.tagId);
  248. form.append("recipientId", this.taskForm.recipientId);
  249. form.append("content", this.taskForm.content);
  250. form.append("publishId", store.getters.token);
  251. if (this.taskForm.delayTime != null) {
  252. form.append("delayTime", this.taskForm.delayTime);
  253. }
  254. if (this.taskForm.id != null) {
  255. //新增的情况
  256. form.append("id", this.taskForm.id);
  257. }
  258. this.taskForm.participantIds.forEach(item => {
  259. form.append("participantIds", item);
  260. });
  261. request({
  262. url: "/task/editTask",
  263. method: "post",
  264. data: form
  265. })
  266. .then(response => {
  267. this.$message({
  268. message: "操作成功",
  269. type: "success"
  270. });
  271. this.getTask();
  272. this.loading = false;
  273. this.taskFormVisible = false;
  274. })
  275. .catch(error => {
  276. this.loading = false;
  277. this.taskFormVisible = false;
  278. });
  279. }
  280. });
  281. },
  282. //打开创建窗口
  283. openInsertDialog() {
  284. this.taskForm.id = null;
  285. this.taskForm.name = "";
  286. this.taskForm.code = "";
  287. this.taskForm.tagId = null;
  288. this.taskForm.planTime = null;
  289. this.taskForm.workload = "";
  290. this.taskForm.publishId = store.getters.token;
  291. this.taskForm.recipientId = null;
  292. this.taskForm.participantIds = [];
  293. this.taskForm.payee = "";
  294. this.taskForm.payer = "";
  295. this.taskForm.fee = "";
  296. this.taskForm.content = "";
  297. this.taskForm.state = 0;
  298. this.taskForm.delayTime = null;
  299. this.taskFormVisible = true;
  300. },
  301. //打开编辑窗口
  302. openUpdateDialog(index) {
  303. this.taskForm.id = this.task[index].id;
  304. this.taskForm.name = this.task[index].name;
  305. this.taskForm.code = this.task[index].code;
  306. this.taskForm.tagId = this.task[index].tagId;
  307. this.taskForm.planTime = this.task[index].planTime;
  308. this.taskForm.workload = this.task[index].workLoad;
  309. this.taskForm.publishId = this.task[index].publishId;
  310. this.taskForm.recipientId = this.task[index].recipientId;
  311. this.taskForm.participantIds = this.info[index].participantId;
  312. this.taskForm.payee = this.task[index].payee;
  313. this.taskForm.payer = this.task[index].payer;
  314. this.taskForm.fee = this.task[index].fee;
  315. this.taskForm.content = this.task[index].content;
  316. this.taskForm.state = this.task[index].state;
  317. this.taskForm.delayTime = this.task[index].delayTime;
  318. this.taskFormVisible = true;
  319. },
  320. //获取任务种类标签
  321. getTags() {
  322. this.loading = true;
  323. request({
  324. url: "/task-tags/getTaskTags",
  325. method: "post",
  326. params: {
  327. pageIndex: this.pageIndex,
  328. pageSize: this.pageSize
  329. }
  330. })
  331. .then(response => {
  332. this.tags = response.data;
  333. this.loading = false;
  334. })
  335. .catch(error => {
  336. this.loading = false;
  337. });
  338. },
  339. //获取用户信息
  340. getUser() {
  341. request({
  342. url: "/user/getUser",
  343. method: "post"
  344. })
  345. .then(response => {
  346. this.user = response.data;
  347. })
  348. .catch(error => {});
  349. },
  350. //表单内选择标签
  351. chooseTag(id) {
  352. this.taskForm.tagId = id;
  353. },
  354. //页码规格变更
  355. handleSizeChange(val) {
  356. this.pageSize = val;
  357. this.getTask();
  358. },
  359. //页码页数变更
  360. handleCurrentChange(val) {
  361. this.pageIndex = val;
  362. this.getTask();
  363. },
  364. //点击开始新增标签
  365. showInput() {
  366. this.newTagVisible = true;
  367. this.newTagValue = "";
  368. this.$nextTick(_ => {
  369. this.$refs.saveTagInput.$refs.input.focus();
  370. });
  371. },
  372. //确认新增标签
  373. handleInputConfirm() {
  374. if (this.newTagValue != "") {
  375. this.$confirm(
  376. "确定要添加新分类" + this.newTagValue + "吗",
  377. "添加标签",
  378. {
  379. confirmButtonText: "确定",
  380. cancelButtonText: "取消",
  381. type: "info"
  382. }
  383. )
  384. .then(() => {
  385. request({
  386. url: "/task-tags/insertTaskTag",
  387. method: "post",
  388. params: { name: this.newTagValue }
  389. })
  390. .then(response => {
  391. this.$message({
  392. type: "success",
  393. message: "添加成功!"
  394. });
  395. this.getTags();
  396. this.newTagVisible = false;
  397. this.newTagValue = "";
  398. })
  399. .catch(error => {
  400. this.newTagVisible = false;
  401. this.newTagValue = "";
  402. });
  403. })
  404. .catch(() => {
  405. this.newTagVisible = false;
  406. this.newTagValue = "";
  407. });
  408. }
  409. },
  410. //点击删除标签
  411. handleClose(id) {
  412. this.$confirm("确定要删除分类吗", "删除分类", {
  413. confirmButtonText: "确定",
  414. cancelButtonText: "取消",
  415. type: "warning"
  416. })
  417. .then(() => {
  418. request({
  419. url: "/task-tags/deleteTaskTag",
  420. method: "post",
  421. params: { id: id }
  422. })
  423. .then(response => {
  424. this.$message({
  425. type: "success",
  426. message: "删除成功!"
  427. });
  428. //这里要清除选中的和表单中的tag
  429. this.taskForm.tagId = null;
  430. this.getTags();
  431. })
  432. .catch(error => {});
  433. })
  434. .catch(() => {});
  435. },
  436. //到详情页面
  437. toDetail(id) {
  438. if (id != null) {
  439. this.$router.push("/task/" + id);
  440. } else {
  441. this.$message({
  442. message: "发生错误",
  443. type: "error"
  444. });
  445. }
  446. }
  447. },
  448. mounted() {
  449. this.getTask();
  450. this.getTags();
  451. this.getUser();
  452. }
  453. };
  454. </script>
  455. <style scoped>
  456. .el-tag + .el-tag {
  457. margin-left: 10px;
  458. }
  459. .button-new-tag {
  460. margin-left: 10px;
  461. height: 32px;
  462. line-height: 30px;
  463. padding-top: 0;
  464. padding-bottom: 0;
  465. }
  466. .input-new-tag {
  467. width: 90px;
  468. margin-left: 10px;
  469. vertical-align: bottom;
  470. }
  471. </style>