PutPhone.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <!-- 申请任务弹窗 -->
  3. <el-dialog
  4. :visible.sync="dialogVisible"
  5. :show-close="false"
  6. width="800px"
  7. :before-close="handleClose"
  8. v-loading="initLoading"
  9. >
  10. <template slot="title">
  11. <div class="dialogTitle">
  12. <div class="dialogTitleIcon"></div>
  13. 发到手机-新建任务
  14. </div>
  15. </template>
  16. <el-form ref="createTaskForm" :model="createTaskForm" :rules="createTaskRrules" label-width="80px">
  17. <el-form-item label="任务名称" prop="c_task_name">
  18. <el-input v-model="createTaskForm.c_task_name" placeholder="请输入任务名称"></el-input>
  19. </el-form-item>
  20. <el-form-item label="关联任务" prop="c_associated_item_ids">
  21. <el-select
  22. v-model="createTaskForm.c_associated_item_ids"
  23. filterable
  24. :loading="selectLoading"
  25. @change="changePorject"
  26. placeholder="请选择"
  27. width="100%"
  28. clearable
  29. >
  30. <el-option
  31. v-for="item in selectSelectDataMap.associatedItemsOptions"
  32. :key="item.value"
  33. :label="item.label"
  34. :value="item.value"
  35. >
  36. </el-option>
  37. </el-select>
  38. </el-form-item>
  39. <el-form-item label="所属街道" prop="c_area_code">
  40. <el-input v-model="c_area_code_str" disabled placeholder="请选择关联任务,自动填入"></el-input>
  41. </el-form-item>
  42. <el-form-item label="任务类型" prop="c_task_type">
  43. <el-input v-model="c_task_type_str" disabled placeholder="请选择关联任务,自动填入"></el-input>
  44. </el-form-item>
  45. <el-form-item label="选择疑点">
  46. <el-cascader
  47. v-model="c_doubtful_pointsList"
  48. :disabled="legendTreeOptionsLoading"
  49. :options="legendTreeOptions"
  50. placeholder="请选择关联任务,动态生成"
  51. :props="cascaderProps"
  52. clearable
  53. ></el-cascader>
  54. </el-form-item>
  55. <!-- <el-form-item label="截止时间" prop="c_end_time">
  56. <el-date-picker v-model="createTaskForm.c_end_time" type="date" placeholder="请选择截止日期"> </el-date-picker>
  57. </el-form-item> -->
  58. <el-form-item label="任务描述" prop="c_task_description">
  59. <el-input
  60. type="textarea"
  61. :autosize="{ minRows: 4, maxRows: 6 }"
  62. placeholder="请描述任务"
  63. v-model="createTaskForm.c_task_description"
  64. width="100%"
  65. ></el-input>
  66. </el-form-item>
  67. </el-form>
  68. <span slot="footer" class="dialog-footer">
  69. <el-button @click="clearDialogVisible('createTaskForm')">取 消</el-button>
  70. <el-button type="primary" @click="subMitDialogVisible('createTaskForm')">确 定</el-button>
  71. </span>
  72. </el-dialog>
  73. </template>
  74. <script>
  75. /**
  76. * 底部菜单(发到手机)组件
  77. * @author: LiuMengxiang
  78. * @Date: 2022年11月21-25日
  79. */
  80. export default {
  81. name: "PutPhone",
  82. components: {},
  83. data() {
  84. return {
  85. initLoading: true,
  86. submitLoading: false,
  87. selectLoading: false,
  88. // 申请任务弹窗显示状态
  89. dialogVisible: false,
  90. legendTree: [],
  91. legendTreeOptionsLoading: true,
  92. legendTreeOptions: [],
  93. cascaderProps: {
  94. multiple: true
  95. },
  96. defaultProps: {
  97. children: "children",
  98. label: "label"
  99. },
  100. c_doubtful_pointsList: [],
  101. // 新建任务form表单
  102. createTaskForm: {
  103. title: "",
  104. content: "申请任务",
  105. c_task_id: "", // 任务id
  106. c_task_name: "", // 任务名称
  107. c_associated_item_ids: "", // 关联项目ids
  108. c_create_time: "", // 当前时间时间戳
  109. c_task_description: "", // 任务描述
  110. c_user_id: "", // 用户id
  111. c_area_code: "", // 所属街道行政区划编码
  112. c_doubtful_points: "", // 疑点信息
  113. c_end_time: "", // 截止时间
  114. c_task_type: "" // 任务类型(所有图层中的某图层栏目名)
  115. },
  116. c_task_type_str: "", // 任务类型中文转义
  117. c_area_code_str: "", // 所属街道行政区划编码中文转义
  118. // 新建任务form表单校验
  119. createTaskRrules: {
  120. c_task_name: [
  121. { required: true, message: "请输入活动名称", trigger: "blur" },
  122. {
  123. min: 3,
  124. max: 20,
  125. message: "长度在 3 到 20 个字符",
  126. trigger: "blur"
  127. }
  128. ],
  129. c_task_type: {
  130. required: true,
  131. message: "请选择任务类型",
  132. trigger: "change"
  133. },
  134. c_associated_item_ids: {
  135. required: true,
  136. message: "请选择关联项目",
  137. trigger: "change"
  138. },
  139. c_area_code: {
  140. required: true,
  141. message: "请选择所属街道",
  142. trigger: "change"
  143. },
  144. c_end_time: {
  145. required: true,
  146. message: "请选择结束时间",
  147. trigger: "change"
  148. },
  149. c_task_description: [
  150. { required: false, message: "请输入任务描述", trigger: "blur" },
  151. {
  152. min: 1,
  153. max: 255,
  154. message: "长度在 1 到 255 个字符",
  155. trigger: "blur"
  156. }
  157. ]
  158. },
  159. // 数据字典暂存对象
  160. selectSelectDataMap: {
  161. projectType: [],
  162. associatedItems: [],
  163. associatedItemsOptions: []
  164. },
  165. streetOfOwnership_str: "",
  166. taskType_str: ""
  167. };
  168. },
  169. created() {
  170. // 首先获取数据字典中的下拉框数据
  171. this.selectSelectData("0", "c_task_type", "projectType");
  172. this.selectSelectData("0", "浦东新区行政区划", "associatedItems");
  173. // 请求所有项目数据
  174. this.getAllPorjects();
  175. },
  176. mounted() {
  177. // 申请任务事件监听
  178. this.$bus.$off("putPhone");
  179. this.$bus.$on("putPhone", () => {
  180. this.changeShowBottomMenusStatus();
  181. });
  182. },
  183. destroy() {
  184. // 当容器销毁时,需要停止监听该事件
  185. this.$bus.$off("putPhone");
  186. },
  187. props: [],
  188. methods: {
  189. // 用户切换关联项目
  190. changePorject(value) {
  191. // 根据项目id得到所属街道和项目类型
  192. this.selectSelectDataMap.associatedItemsOptions.forEach(item => {
  193. if (item.value == value) {
  194. this.createTaskForm.c_area_code = item.c_area_code;
  195. this.createTaskForm.c_task_type = item.c_task_type;
  196. }
  197. });
  198. // 所属街道遍历渲染
  199. this.selectSelectDataMap.projectType.forEach(item => {
  200. if (item.index == this.createTaskForm.c_task_type) {
  201. this.c_task_type_str = item.name;
  202. }
  203. });
  204. // 任务类型遍历渲染
  205. this.selectSelectDataMap.associatedItems.forEach(item => {
  206. if (item.index == this.createTaskForm.c_area_code) {
  207. this.c_area_code_str = item.name;
  208. }
  209. });
  210. this.$bus.$emit("openMyTask", [this.createTaskForm.c_task_type, this.createTaskForm.c_area_code]);
  211. },
  212. // 数据字典查询
  213. selectSelectData(type, cName, keyName) {
  214. let params = new FormData();
  215. params.append("type", type);
  216. params.append("cName", cName);
  217. this.$Post(this.urlsCollection.selectByCNameAType, params).then(
  218. res => {
  219. if (res.code === 200 && res.content.length > 0) {
  220. this.selectSelectDataMap[keyName] = res.content;
  221. }
  222. },
  223. error => {
  224. this.$message.error(error);
  225. console.log(error);
  226. }
  227. );
  228. },
  229. // 请求获取所有关联项目数据
  230. getAllPorjects() {
  231. if (!this.initLoading) {
  232. this.initLoading = true;
  233. }
  234. let params = new FormData();
  235. params.append("columnId", "48");
  236. params.append("states", "2,3");
  237. params.append("pageSize", 999);
  238. params.append("page", 0);
  239. let sortparam = [{ field: "c_create_time", orderByType: 2 }];
  240. params.append("orderBy", JSON.stringify(sortparam));
  241. this.$Post(this.urlsCollection.selectContentList, params).then(
  242. res => {
  243. if (res.code === 200 && res.content.data.length > 0) {
  244. let associatedItemsOptionsData = res.content.data;
  245. associatedItemsOptionsData.filter(item => {
  246. this.selectSelectDataMap.associatedItemsOptions.push({
  247. label: item.c_task_name,
  248. value: item.id,
  249. c_area_code: item.c_area_code,
  250. c_task_type: item.c_task_type
  251. });
  252. });
  253. this.initLoading = false;
  254. } else {
  255. this.initLoading = false;
  256. this.$message.error(res.message);
  257. }
  258. },
  259. error => {
  260. this.initLoading = false;
  261. this.$message.error(error);
  262. }
  263. );
  264. },
  265. remoteMethod(query) {
  266. if (query !== "") {
  267. this.selectLoading = true;
  268. setTimeout(() => {
  269. // 开始动态请求服务器数据并赋值给options对象
  270. this.selectLoading = false;
  271. this.selectSelectDataMap.associatedItemsOptions = [];
  272. }, 200);
  273. } else {
  274. this.selectSelectDataMap.associatedItemsOptions = [];
  275. }
  276. },
  277. // 当用户点击svg底座时,切换底部菜单显示隐藏状态。
  278. changeShowBottomMenusStatus() {
  279. // 打开弹窗
  280. this.dialogVisible = true;
  281. this.$emit("changeShowBottomMenusStatus", false);
  282. },
  283. // 弹窗关闭询问
  284. handleClose() {
  285. if (this.dialogVisible) {
  286. this.$confirm("确认关闭?")
  287. .then(_ => {
  288. this.clearDialogVisible("createTaskForm");
  289. })
  290. .catch(_ => {});
  291. }
  292. },
  293. // 申请任务取消
  294. clearDialogVisible(formName) {
  295. // 关闭弹窗
  296. this.dialogVisible = false;
  297. // 重置表单
  298. this.$refs[formName].resetFields();
  299. // 修改父级菜单变量(弹窗显示状态和显示底部菜单)
  300. this.$emit("changeShowBottomMenusStatus", true);
  301. },
  302. // 申请任务提交
  303. subMitDialogVisible(formName) {
  304. // 表单校验
  305. this.$refs[formName].validate(valid => {
  306. if (valid) {
  307. if (this.c_doubtful_pointsList) {
  308. this.c_doubtful_pointsList.forEach(item => {
  309. this.createTaskForm.c_doubtful_points = item[1];
  310. this.createTaskForm.c_task_id = this.$CryptoJS.buildGuid();
  311. this.createTaskForm.c_user_id = localStorage.getItem("USER_ID");
  312. this.createTaskForm.c_create_time = parseInt(new Date().getTime() / 1000) * 1000;
  313. this.createTaskForm.title = this.createTaskForm.c_task_name;
  314. // 开始提交
  315. let params = new FormData();
  316. params.append("columnId", "1537");
  317. params.append("modelId", "909");
  318. params.append("content", JSON.stringify(this.createTaskForm));
  319. this.$Post(this.urlsCollection.addContent, params).then(
  320. res => {
  321. if (res.code === 200) {
  322. this.$message.success(res.message);
  323. this.submitLoading = false;
  324. } else {
  325. this.submitLoading = false;
  326. this.$message.error(res.message);
  327. }
  328. },
  329. error => {
  330. this.submitLoading = false;
  331. this.$message.error(error);
  332. }
  333. );
  334. });
  335. }
  336. setTimeout(() => {
  337. // 检验成功后关闭弹窗
  338. this.clearDialogVisible(formName);
  339. }, 0);
  340. } else {
  341. return false;
  342. }
  343. });
  344. },
  345. getAllLegendData() {
  346. if (this.legendTree.children.length > 0) {
  347. this.legendTreeOptionsLoading = true;
  348. this.legendTree.children.forEach(item => {
  349. this.getLegendData(item.columnId, item.label);
  350. });
  351. this.legendTreeOptionsLoading = false;
  352. }
  353. },
  354. getLegendData(columnId, label) {
  355. let layerParams = new FormData();
  356. layerParams = {
  357. columnId: columnId,
  358. states: "0,1,2,3",
  359. pageSize: 10,
  360. page: 0
  361. };
  362. this.$Post(this.urlsCollection.selectContentList, layerParams).then(
  363. res => {
  364. // if (res.code === 202 && res.content === "数据不存在") {
  365. // this.$message.info("暂无数据!");
  366. // }
  367. if (res.code === 200 && res.content.data.length > 0) {
  368. // 初始化时将请求到的疑点数据中是否疑点全部改为未标记,疑点,非疑点三种状态
  369. let childrens = res.content.data.map(item => {
  370. if (item.c_content) {
  371. let conetentJson = JSON.parse(item.c_content);
  372. // console.log(conetentJson.id, conetentJson.properties["图斑编号"]);
  373. return {
  374. label: conetentJson.id,
  375. value: item.c_content
  376. };
  377. }
  378. });
  379. this.legendTreeOptions.push({
  380. value: columnId,
  381. label: label,
  382. children: childrens
  383. });
  384. }
  385. },
  386. error => {
  387. this.$message.error("请求错误!");
  388. }
  389. );
  390. }
  391. },
  392. watch: {
  393. "$store.state.legendTree": {
  394. handler(val) {
  395. if (val && val.length > 0) {
  396. val.forEach(item => {
  397. if (item.label == this.c_task_type_str) {
  398. this.legendTree = item;
  399. this.getAllLegendData();
  400. }
  401. });
  402. }
  403. }
  404. }
  405. }
  406. };
  407. </script>