index.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. import Vue from "vue";
  2. import { base } from "@/configue/base";
  3. import { axios, serverName } from "@/configue/http";
  4. import { isImage, isTypeBySend, cloneObject, isNull } from "@/util/index.js";
  5. import { del, applyDetail, apply } from "@/configue/api";
  6. Vue.prototype.$base = base;
  7. Vue.prototype.$bus = new Vue();
  8. Vue.prototype.$http = axios;
  9. Vue.prototype.isImage = isImage;
  10. Vue.prototype.isTypeBySend = isTypeBySend;
  11. Vue.prototype.INPUTLENGTH = 20;
  12. Vue.prototype.PAGESIZES = [25, 50, 75, 100];
  13. Vue.prototype.UNITS = [{
  14. name:'第一层',
  15. id:'1'
  16. },{
  17. name:'第二层',
  18. id:'2'
  19. }]
  20. Vue.prototype.loading = {
  21. close() {},
  22. };
  23. Vue.prototype.loadOption = {
  24. lock: true,
  25. text: "上传中",
  26. spinner: "el-icon-loading",
  27. background: "rgba(0, 0, 0, 0.7)",
  28. };
  29. Vue.prototype.statusStr = {
  30. all: "全部",
  31. 0: "草稿中",
  32. 1: "待审核",
  33. 2: "审核不通过",
  34. 3: "审核通过",
  35. };
  36. Vue.prototype.statusArr = [
  37. {
  38. id: "all",
  39. name: "全部",
  40. },
  41. {
  42. id: 0,
  43. name: "草稿中",
  44. },
  45. {
  46. id: 1,
  47. name: "待审核",
  48. },
  49. {
  50. id: 2,
  51. name: "审核不通过",
  52. },
  53. {
  54. id: 3,
  55. name: "审核通过",
  56. },
  57. ];
  58. Vue.prototype.sysRole = [
  59. {
  60. name: "系统管理员",
  61. id: "sys_admin",
  62. },
  63. {
  64. name: "高级管理员",
  65. id: "sys_high",
  66. },
  67. {
  68. name: "普通用户",
  69. id: "sys_normal",
  70. },
  71. {
  72. name: "-",
  73. id: "sys_visitor",
  74. },
  75. ];
  76. Vue.prototype.collectType = {
  77. 1: "专题图库",
  78. 2: "视频文件",
  79. 3: "模型文件",
  80. };
  81. Vue.prototype.juese = {
  82. sys_admin: "系统管理员",
  83. sys_content: "内容管理员",
  84. sys_audit: "审核管理员"
  85. };
  86. Vue.prototype.sex = {
  87. 0: "男",
  88. 1: "女",
  89. };
  90. Vue.prototype.$serverName = serverName; // 挂载到Vue实例上面
  91. let g_political = [{
  92. val:'群众'
  93. },{
  94. val:'团员'
  95. },{
  96. val:'党员'
  97. },{
  98. val:'预备党员'
  99. }]
  100. let g_expert = [{
  101. val:'一级',
  102. id:1
  103. },{
  104. val:'二级',
  105. id:2
  106. },{
  107. val:'三级',
  108. id:3
  109. },{
  110. val:'院士',
  111. id:4
  112. },{
  113. val:'英模代表专家',
  114. id:6
  115. },{
  116. val:'其他',
  117. id:5
  118. }]
  119. import MainTop from "@/components/main-top";
  120. import search from "@/components/search";
  121. import accordion from "@/components/accordion";
  122. import status from "@/components/status";
  123. import vtable from "@/components/table";
  124. import dialog from "@/components/dialog";
  125. import editcon from "@/components/editcomponent/editcon";
  126. import editdialog from "@/components/editcomponent/editdialog";
  127. Vue.mixin({
  128. components: {
  129. MainTop,
  130. accordion,
  131. search,
  132. vtable,
  133. status,
  134. editcon,
  135. editdialog,
  136. vdialog: dialog,
  137. },
  138. data(){
  139. return {
  140. g_political,
  141. g_expert
  142. }
  143. },
  144. methods: {
  145. cloneObject,
  146. isNull,
  147. validate(cb) {
  148. let child = this.$refs.child;
  149. child.$refs[this.type].validate(async (valid) => {
  150. if (valid) {
  151. if (status == 2) {
  152. this.$confirm("请再次确认是否进行此操作?", "提示", {
  153. confirmButtonText: "确定",
  154. cancelButtonText: "取消",
  155. type: "warning",
  156. })
  157. .then(async () => {
  158. cb();
  159. })
  160. .catch(() => {
  161. this.$message({
  162. type: "info",
  163. message: "已取消",
  164. });
  165. });
  166. } else {
  167. cb();
  168. }
  169. }
  170. });
  171. },
  172. confirm(msg, res) {
  173. this.$confirm(msg, "提示", {
  174. confirmButtonText: "确定",
  175. cancelButtonText: "取消",
  176. type: "warning",
  177. })
  178. .then(() => {
  179. res();
  180. })
  181. .catch(() => {});
  182. },
  183. backList() {
  184. let name = this.$route.meta.index;
  185. let { type } = this.$route.params;
  186. this.$router.replace({
  187. name: name,
  188. params: {
  189. type,
  190. },
  191. });
  192. },
  193. goto(item) {
  194. let { type } = this.$route.params;
  195. console.log(type);
  196. this.$router.push({
  197. name: "edit-" + this.$route.name,
  198. params: {
  199. id: item.id,
  200. type: type,
  201. },
  202. });
  203. },
  204. del(data) {
  205. let { item, type } = data;
  206. this.confirm("删除后,信息将无法恢复,是否继续?", () => {
  207. del(
  208. type,
  209. {
  210. id: item.id,
  211. },
  212. () => {
  213. this.$alert("删除成功", "提示", {
  214. confirmButtonText: "确定",
  215. callback: () => {
  216. let tmp = this.getList ? "getList" : "backList";
  217. this[tmp]();
  218. },
  219. });
  220. }
  221. );
  222. });
  223. },
  224. audit(item) {
  225. let { type } = this.$route.params;
  226. this.$router.push({
  227. name: "edit-" + this.$route.name,
  228. params: { id: item.id, type: type },
  229. query: { isAudit: true },
  230. });
  231. },
  232. applyDetail(item, type) {
  233. applyDetail(type, { id: item.id }, (res) => {
  234. this.showApplyDetail = true;
  235. this.alDetail = res;
  236. });
  237. },
  238. submit(data,hadTwoParam=null) {
  239. let item = ''
  240. let type = ''
  241. if (hadTwoParam) {
  242. item = data
  243. type = hadTwoParam
  244. this.confirm("提交后,信息将保存并且进入审核,是否继续?", () => {
  245. this.save('submit',()=>{
  246. apply(type, { id: item.id }, () => {
  247. this.$alert("提交成功", "提示", {
  248. confirmButtonText: "确定",
  249. callback: () => {
  250. let tmp = this.getList ? "getList" : "backList";
  251. this[tmp]();
  252. },
  253. });
  254. });
  255. })
  256. });
  257. }
  258. else{
  259. item = data.item
  260. type = data.type
  261. this.confirm("提交后,信息将进入审核,是否继续?", () => {
  262. apply(type, { id: item.id }, () => {
  263. this.$alert("提交成功", "提示", {
  264. confirmButtonText: "确定",
  265. callback: () => {
  266. let tmp = this.getList ? "getList" : "backList";
  267. this[tmp]();
  268. },
  269. });
  270. });
  271. });
  272. }
  273. },
  274. determine() {
  275. let { isAudit } = this.$route.query;
  276. if (this.status === 1) {
  277. if (isAudit) {
  278. this.showAudit = true;
  279. return;
  280. }
  281. }
  282. this.backList();
  283. },
  284. getAuth(menu, key) {
  285. if (!menu) return;
  286. let auth = {};
  287. if (key == "场景" || key == '专家' || key=='沙盘' || key=='用户' || key=='角色' || key=='日志') {
  288. menu.children && menu.children.forEach((item) => {
  289. auth[item.name] = item.authority;
  290. });
  291. this.$store.commit("SetActiveSub", auth);
  292. } else {
  293. let temp =
  294. menu.children &&
  295. menu.children.find((item) => item.name.indexOf(key) > -1);
  296. console.log(menu, key);
  297. if (!temp) return;
  298. temp.children.forEach((item) => {
  299. auth[item.name] = item.authority;
  300. });
  301. this.$store.commit("SetActiveSub", auth);
  302. console.log(auth);
  303. }
  304. },
  305. },
  306. watch: {
  307. page: {
  308. deep: true,
  309. handler: function() {
  310. this.getList && this.getList();
  311. },
  312. }
  313. },
  314. });