MyMission.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <!-- 我的任务弹窗 fullscreen -->
  3. <el-dialog
  4. custom-class="myMission"
  5. title="我的任务"
  6. :visible.sync="dialogVisible"
  7. width="70%"
  8. height="60%"
  9. :before-close="handleClose"
  10. >
  11. <template slot="title">
  12. <div class="dialogTitle">
  13. <div class="dialogTitleIcon"></div>
  14. 我的任务
  15. </div>
  16. </template>
  17. <el-form :inline="true" ref="myTaskForm" :model="formInline">
  18. <el-form-item label="任务类型">
  19. <el-select v-model="formInline.taskType" filterable placeholder="请选择" width="100%" clearable>
  20. <el-option v-for="item in selectSelectDataMap.projectType" :key="item.index" :label="item.name" :value="item.index">
  21. </el-option>
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="关联项目">
  25. <el-select size="mini" v-model="formInline.associatedItems" placeholder="关联项目" clearable filterable>
  26. <el-option
  27. v-for="item in selectSelectDataMap.associatedItemsOptions"
  28. :key="item.value"
  29. :label="item.label"
  30. :value="item.value"
  31. >
  32. </el-option>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item label="审计状态">
  36. <el-select size="mini" v-model="formInline.auditStatus" placeholder="审计状态" clearable>
  37. <el-option label="已审核" value="2,3"></el-option>
  38. <el-option label="未审核" value="0,1"></el-option>
  39. </el-select>
  40. </el-form-item>
  41. <el-form-item style="float: right">
  42. <el-button type="primary" @click="onSubmit">查询</el-button>
  43. <el-button @click="resetForm()">重置</el-button>
  44. </el-form-item>
  45. </el-form>
  46. <el-table
  47. :data="tableData"
  48. style="width: 100%"
  49. height="calc(80vh - 400px)"
  50. stripe
  51. @row-click="ToView"
  52. v-loading="tableInitLoading"
  53. >
  54. <el-table-column type="index" width="50"> </el-table-column>
  55. <!-- <el-table-column prop="c_task_id" label="任务编号"> </el-table-column> -->
  56. <el-table-column prop="c_task_name" label="任务名称"> </el-table-column>
  57. <el-table-column prop="c_create_time" label="创建时间">
  58. <template slot-scope="scope">
  59. {{ $dayjs(scope.row.c_create_time).format("YYYY-MM-DD HH:mm:ss") }}
  60. </template>
  61. </el-table-column>
  62. <el-table-column prop="state" label="状态">
  63. <template slot-scope="scope">
  64. <el-tag :type="scope.row.state >= 2 ? 'success' : 'info'" disable-transitions>{{
  65. scope.row.state >= 2 ? "已审核" : "未审核"
  66. }}</el-tag>
  67. </template>
  68. </el-table-column>
  69. <el-table-column prop="c_task_type" label="任务类型">
  70. <template slot-scope="scope">
  71. {{ getSelectByIndex("projectType", scope.row.c_task_type) }}
  72. </template>
  73. </el-table-column>
  74. <el-table-column prop="c_area_code" label="所属街镇">
  75. <template slot-scope="scope">
  76. {{ getSelectByIndex("associatedItems", scope.row.c_area_code) }}
  77. </template></el-table-column
  78. >
  79. </el-table>
  80. <span slot="footer" class="dialog-footer">
  81. <Pagination :paginationData="paginationData" />
  82. </span>
  83. </el-dialog>
  84. </template>
  85. <script>
  86. /**
  87. * 底部菜单(我的任务)组件
  88. * @author: LiuMengxiang
  89. * @Date: 2022年11月21-25日
  90. */
  91. import Pagination from "../Pagination.vue";
  92. export default {
  93. name: "MyMission",
  94. components: { Pagination },
  95. data() {
  96. return {
  97. tableInitLoading: false,
  98. // 我的任务弹窗显示状态
  99. dialogVisible: false,
  100. // 查询条件
  101. formInline: {
  102. taskType: "",
  103. associatedItems: "",
  104. auditStatus: ""
  105. },
  106. // 数据字典暂存对象
  107. selectSelectDataMap: {
  108. projectType: [],
  109. associatedItems: [],
  110. associatedItemsOptions: []
  111. },
  112. // 分页组件(根据后台返回结果赋值)
  113. paginationData: {
  114. pageSize: 5,
  115. pageSizes: [5, 10, 20, 50],
  116. total: 0,
  117. currentPage: 1,
  118. currentChange: val => {
  119. this.handleCurrentChange(val);
  120. },
  121. handleSizeChange: val => {
  122. this.handleSizeChange(val);
  123. }
  124. },
  125. // 任务类型options
  126. taskTypeOptions: [],
  127. // 关联项目options
  128. associatedItemsOptions: [],
  129. // 我的任务form表单
  130. tableData: []
  131. };
  132. },
  133. created() {
  134. // 我的任务事件监听
  135. this.$bus.$off("wdrw");
  136. this.$bus.$on("wdrw", () => {
  137. this.changeShowBottomMenusStatus();
  138. });
  139. },
  140. destroy() {
  141. // 当容器销毁时,需要停止监听该事件
  142. this.$bus.$off("wdrw");
  143. },
  144. props: [],
  145. methods: {
  146. // 数据字典对照显示
  147. getSelectByIndex(selectName, index) {
  148. let slotValue = "";
  149. if (this.selectSelectDataMap[selectName] && this.selectSelectDataMap[selectName].length > 0) {
  150. this.selectSelectDataMap[selectName].forEach(item => {
  151. if (item.index == index) {
  152. slotValue = item.name;
  153. }
  154. });
  155. }
  156. return slotValue;
  157. },
  158. // 请求获取所有关联项目数据
  159. getAllPorjects() {
  160. if (!this.initLoading) {
  161. this.initLoading = true;
  162. }
  163. let params = new FormData();
  164. params.append("columnId", "29");
  165. params.append("states", "2,3");
  166. params.append("pageSize", 999);
  167. params.append("page", 0);
  168. let sortparam = [{ field: "c_create_time", orderByType: 2 }];
  169. params.append("orderBy", JSON.stringify(sortparam));
  170. this.$Post(this.urlsCollection.selectContentList, params).then(
  171. res => {
  172. if (res.code === 200 && res.content.data.length > 0) {
  173. let associatedItemsOptionsData = res.content.data;
  174. associatedItemsOptionsData.filter(item => {
  175. this.selectSelectDataMap.associatedItemsOptions.push({
  176. label: item.c_project_name,
  177. value: item.id,
  178. c_owning_street_town: item.c_owning_street_town,
  179. c_task_type: item.c_task_type
  180. });
  181. });
  182. this.initLoading = false;
  183. } else {
  184. this.initLoading = false;
  185. this.$message.error(res.message);
  186. }
  187. },
  188. error => {
  189. this.initLoading = false;
  190. this.$message.error(error);
  191. }
  192. );
  193. },
  194. // 切换条数
  195. handleSizeChange(val) {
  196. this.paginationData.pageSize = val;
  197. this.onSubmit();
  198. },
  199. // 切换页
  200. handleCurrentChange(val) {
  201. this.paginationData.currentPage = val;
  202. this.onSubmit();
  203. },
  204. // 查询事件
  205. onSubmit() {
  206. if (!this.tableInitLoading) {
  207. this.tableInitLoading = true;
  208. let params = new FormData();
  209. params.append("columnId", "48");
  210. params.append("pageSize", this.paginationData.pageSize);
  211. params.append("page", this.paginationData.currentPage - 1);
  212. let searchParam = [];
  213. let param = {
  214. field: "c_user_id",
  215. searchType: "1",
  216. content: {
  217. value: localStorage.getItem("USER_ID")
  218. }
  219. };
  220. searchParam.push(param);
  221. if (this.formInline.taskType) {
  222. let param1 = {
  223. field: "c_task_type",
  224. searchType: "1",
  225. content: {
  226. value: this.formInline.taskType
  227. }
  228. };
  229. searchParam.push(param1);
  230. }
  231. if (this.formInline.associatedItems) {
  232. let param1 = {
  233. field: "c_associated_item_ids",
  234. searchType: "2",
  235. content: {
  236. value: this.formInline.associatedItems
  237. }
  238. };
  239. searchParam.push(param1);
  240. }
  241. if (this.formInline.auditStatus) {
  242. params.append("states", this.formInline.auditStatus);
  243. } else {
  244. params.append("states", "0,1,2,3");
  245. }
  246. params.append("search", JSON.stringify(searchParam));
  247. let sortparam = [{ field: "c_create_time", orderByType: 2 }];
  248. params.append("orderBy", JSON.stringify(sortparam));
  249. this.$Post(this.urlsCollection.selectContentList, params).then(
  250. res => {
  251. if (res.code === 200 && res.content.data.length > 0) {
  252. this.tableData = res.content.data;
  253. this.tableInitLoading = false;
  254. this.paginationData.total = res.content.count;
  255. } else {
  256. this.tableData = [];
  257. this.tableInitLoading = false;
  258. this.$message.error(res.message);
  259. }
  260. },
  261. error => {
  262. this.tableData = [];
  263. this.tableInitLoading = false;
  264. this.$message.error(error);
  265. }
  266. );
  267. }
  268. },
  269. // 查询条件重置
  270. resetForm() {
  271. this.formInline = {
  272. taskType: "",
  273. associatedItems: "",
  274. auditStatus: ""
  275. };
  276. this.onSubmit();
  277. },
  278. // 单击table item
  279. ToView(val) {
  280. if(val.state >= 2){
  281. // 调用全局事件总线中的指定事件
  282. this.$bus.$emit("openMyTask",[val.c_task_type,val.c_area_code]);
  283. this.handleClose();
  284. }
  285. },
  286. // 当用户点击svg底座时,切换底部菜单显示隐藏状态。
  287. changeShowBottomMenusStatus() {
  288. // 打开弹窗
  289. if (!this.dialogVisible) {
  290. this.dialogVisible = true;
  291. if (this.$ifMenu("3", "")) {
  292. if (this.selectSelectDataMap.projectType.length === 0) {
  293. // 首先获取数据字典中的下拉框数据
  294. this.selectSelectData("0", "c_task_type", "projectType");
  295. this.selectSelectData("0", "浦东新区行政区划", "associatedItems");
  296. // 请求所有项目数据
  297. this.getAllPorjects();
  298. }
  299. this.onSubmit();
  300. this.$emit("changeShowBottomMenusStatus", false);
  301. }
  302. }
  303. },
  304. // 数据字典查询
  305. selectSelectData(type, cName, keyName) {
  306. let params = new FormData();
  307. params.append("type", type);
  308. params.append("cName", cName);
  309. this.$Post(this.urlsCollection.selectByCNameAType, params).then(
  310. res => {
  311. if (res.code === 200 && res.content.length > 0) {
  312. this.selectSelectDataMap[keyName] = res.content;
  313. }
  314. },
  315. error => {
  316. this.$message.error(error);
  317. console.log(error);
  318. }
  319. );
  320. },
  321. // 弹窗关闭询问
  322. handleClose() {
  323. if (this.dialogVisible) {
  324. this.clearDialogVisible();
  325. // this.$confirm("确认关闭?")
  326. // .then(_ => {
  327. // this.clearDialogVisible();
  328. // })
  329. // .catch(_ => {});
  330. }
  331. },
  332. // 我的任务取消
  333. clearDialogVisible() {
  334. // 关闭弹窗
  335. this.dialogVisible = false;
  336. // 修改父级菜单变量(弹窗显示状态和显示底部菜单)
  337. if (this.$ifMenu("3", "")) {
  338. this.$emit("changeShowBottomMenusStatus", true);
  339. }
  340. }
  341. },
  342. watch: {}
  343. };
  344. </script>