home.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <template>
  2. <el-container class="home">
  3. <!-- 顶部导航栏 -->
  4. <el-header class="header">
  5. <Select width="200" radius @change="testClick" :selectdata="dataSelect3" :placeholder="'请选择'" />
  6. <Button radius @click="createProject" type="primary" :text="'新建拓扑图'">primary</Button>
  7. </el-header>
  8. <!-- body部分 -->
  9. <el-container class="bodys">
  10. <!-- 左侧树状导航栏部分 -->
  11. <el-aside class="aside" width="200px">
  12. <leftAsideTree ref="leftAsideTree" @changeNode="changeNode"></leftAsideTree>
  13. </el-aside>
  14. <!-- 展示部分 -->
  15. <el-main class="main">
  16. <div class="main-head">
  17. <div class="showType" v-show="!selectCard.length">
  18. <el-radio-group v-model="isPub" size="small" @change="changePub">
  19. <el-radio-button :label="1">已发布</el-radio-button>
  20. <el-radio-button :label="0">未发布</el-radio-button>
  21. </el-radio-group>
  22. <div class="head-right">
  23. <el-input placeholder="搜索" prefix-icon="el-icon-search" size="small" v-model="queryText" @change="changeQueryText">
  24. </el-input>
  25. <Dropdown class="Dropdown" v-model="selVal" :data="dataSelect">
  26. <span class="drop-text">{{selText}}</span>
  27. </Dropdown>
  28. </div>
  29. </div>
  30. <div class="showAction" v-show="selectCard.length">
  31. <el-checkbox v-model="checkAll" :indeterminate="isIndeterminate" @change="handleCheckAllChange">全选</el-checkbox>
  32. <span style="margin-left: 10px;">|</span>
  33. <span class="sum">已选择<span style="color:#252b30;margin: 0 5px;">{{selectCard.length}}</span>项目</span>
  34. <el-button size="mini" @click="groupMove">移动到</el-button>
  35. <el-button size="mini" @click="groupDownload" v-if="isPub">下载</el-button>
  36. <el-button size="mini" @click="groupDelete">删除</el-button>
  37. <i class="el-icon-close" style="float:right;line-height: 28px;margin-right: 5px;" @click="handleCheckAllChange(false)"></i>
  38. </div>
  39. </div>
  40. <div class="main-body" :class="{'no-data': !cardList.length}">
  41. <template v-for="t in cardList">
  42. <topoImageCard :data="t" :key="t.id" @changeCheck="changeCheck" @rename="rename" @publishSuc="updateSuc" @moveTo="moveTo"
  43. @delete="deleteGraph"></topoImageCard>
  44. </template>
  45. <div v-if="!cardList.length" style="margin-top: 112px;">
  46. <img src="./../assets/images/no-data.png" alt="" style="width: 116px;height:116px;">
  47. <p style="font-size: 16px;margin-top: 15px;text-align:center;">暂无数据</p>
  48. </div>
  49. </div>
  50. </el-main>
  51. </el-container>
  52. <!-- 弹框 -->
  53. <el-dialog class="create-dialog" title="新建拓扑图" :visible.sync="outerVisible">
  54. <el-dialog class="create-dialog-inner" width="30%" title="所属类别" :visible.sync="innerVisible" append-to-body>
  55. <div class="inner-dialog-body">
  56. <div class="left">1</div>
  57. <div class="right">2</div>
  58. </div>
  59. </el-dialog>
  60. <div class="dialog-bodys">
  61. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm" label-position="top">
  62. <el-form-item label="所属类别" prop="region">
  63. <el-button @click="getprojectType">请选择所属类别</el-button>
  64. </el-form-item>
  65. <el-form-item label="活动名称" prop="name">
  66. <el-input v-model="ruleForm.name"></el-input>
  67. </el-form-item>
  68. <el-form-item label="标签" prop="resource">
  69. <el-select v-model="value" multiple filterable allow-create default-first-option width="100%" placeholder="请选择文章标签"></el-select>
  70. </el-form-item>
  71. <el-form-item>
  72. <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
  73. <el-button @click="resetForm('ruleForm')">重置</el-button>
  74. </el-form-item>
  75. </el-form>
  76. </div>
  77. <div slot="footer" class="dialog-footer">
  78. <el-button @click="outerVisible = false">取 消</el-button>
  79. <el-button type="primary" @click="innerVisible = true">确定</el-button>
  80. </div>
  81. </el-dialog>
  82. <!-- 重命名 -->
  83. <rename ref="rename" @updateSuc="updateSuc"></rename>
  84. <!-- 移动到 -->
  85. <move ref="move" @moveSuc="moveSuc"></move>
  86. <!-- 删除二次确认 -->
  87. <deleteDialog ref="deleteDialog" @deleteSuc="deleteSuc"></deleteDialog>
  88. </el-container>
  89. </template>
  90. <script>
  91. import { Select, Button, Dropdown } from "meri-design";
  92. import leftAsideTree from "@/components/homeView/leftAsideTree.vue";
  93. import topoImageCard from "@/components/homeView/topoImageCard.vue";
  94. import { queryDraftsGraph, queryPubGraph } from "@/api/home"
  95. import rename from "@/components/homeView/rename"
  96. import move from "@/components/homeView/move"
  97. import deleteDialog from "@/components/homeView/deleteDialog"
  98. export default {
  99. name: "home",
  100. data() {
  101. return {
  102. dataSelect3: [
  103. { id: "test1", name: "选择项", sub: "hello111" },
  104. { id: "test2", name: "单平米", sub: "hola111" },
  105. {
  106. id: "test3",
  107. name: "下级分项",
  108. sub: "bonjour",
  109. divider: true,
  110. },
  111. { id: "test4", name: "滑动平均滑动平均", sub: "hi" },
  112. ], // 项目列表
  113. selVal: "lastUpdate", // 排序方式
  114. selText: "按最后修改", // 排序方式文字
  115. dataSelect: [
  116. { id: "lastUpdate", name: "按最后修改" },
  117. { id: "name", name: "按字母顺序" },
  118. { id: "createTime", name: "按创建时间" }
  119. ], // 排序选项
  120. queryText: "", // 搜索文字
  121. isPub: 1, // 发布类型()
  122. outerVisible: false,
  123. innerVisible: false,
  124. ruleForm: {
  125. name: "",
  126. region: "",
  127. date1: "",
  128. date2: "",
  129. delivery: false,
  130. type: [],
  131. resource: "",
  132. desc: "",
  133. },
  134. rules: {
  135. name: [
  136. { required: true, message: "请输入活动名称", trigger: "blur" },
  137. { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
  138. ],
  139. region: [
  140. { required: true, message: "请选择活动区域", trigger: "change" },
  141. ],
  142. date1: [
  143. {
  144. type: "date",
  145. required: true,
  146. message: "请选择日期",
  147. trigger: "change",
  148. },
  149. ],
  150. date2: [
  151. {
  152. type: "date",
  153. required: true,
  154. message: "请选择时间",
  155. trigger: "change",
  156. },
  157. ],
  158. type: [
  159. {
  160. type: "array",
  161. required: true,
  162. message: "请至少选择一个活动性质",
  163. trigger: "change",
  164. },
  165. ],
  166. resource: [
  167. { required: true, message: "请选择活动资源", trigger: "change" },
  168. ],
  169. desc: [{ required: true, message: "请填写活动形式", trigger: "blur" }],
  170. },
  171. value: [],
  172. cardList: [], // 当前显示的卡片列表
  173. checkAll: false, // 全选
  174. selectCard: [], // 当前选中的卡片列表
  175. isIndeterminate: true, // 全选按钮
  176. curCategory: {}, // 当前选中的树节点
  177. };
  178. },
  179. mounted() {
  180. },
  181. methods: {
  182. testClick(data) {
  183. console.log(data);
  184. },
  185. // 创建拓扑图
  186. createProject() { },
  187. // 获取所属类别
  188. getprojectType() {
  189. this.innerVisible = true;
  190. },
  191. submitForm(formName) {
  192. this.$refs[formName].validate((valid) => {
  193. if (valid) {
  194. alert("submit!");
  195. } else {
  196. console.log("error submit!!");
  197. return false;
  198. }
  199. });
  200. },
  201. resetForm(formName) {
  202. this.$refs[formName].resetFields();
  203. },
  204. // 选项改变
  205. changeCheck(v) {
  206. const index = this.selectCard.indexOf(v);
  207. if (index > -1) {
  208. this.selectCard.splice(index, 1);
  209. } else {
  210. this.selectCard.push(v);
  211. }
  212. },
  213. // 全选按钮
  214. handleCheckAllChange(val) {
  215. this.cardList = this.cardList.map(t => {
  216. t.checked = val
  217. return t;
  218. })
  219. this.selectCard = val ? this.cardList.map(t => { t.checked = true; return t }) : [];
  220. this.isIndeterminate = false;
  221. },
  222. // 批量移动到
  223. groupMove() {
  224. this.$refs.move.showDialog(this.selectCard)
  225. },
  226. // 下载
  227. groupDownload() {
  228. console.log('download');
  229. },
  230. // 删除
  231. groupDelete() {
  232. this.$refs.deleteDialog.showDialog(this.selectCard);
  233. },
  234. // 重命名
  235. rename(data) {
  236. this.$refs.rename.showDialog(data)
  237. },
  238. // 移动到
  239. moveTo(data) {
  240. this.$refs.move.showDialog([data])
  241. },
  242. // 单独删除
  243. deleteGraph(data) {
  244. this.$refs.deleteDialog.showDialog([data]);
  245. },
  246. // 更新成功-发布成功
  247. updateSuc() {
  248. this.queryGraph()
  249. },
  250. // 移动成功
  251. moveSuc() {
  252. this.queryGraph()
  253. this.$refs.leftAsideTree.getCategoryGraph();
  254. },
  255. // 删除成功
  256. deleteSuc() {
  257. this.queryGraph()
  258. this.$refs.leftAsideTree.getCategoryGraph();
  259. },
  260. // 选中节点变化
  261. changeNode(data) {
  262. this.curCategory = data;
  263. this.queryGraph()
  264. },
  265. // 发布修改
  266. changePub() {
  267. this.queryGraph()
  268. },
  269. // 输入内容变化
  270. changeQueryText() {
  271. this.queryGraph()
  272. },
  273. /////////////////接口
  274. // 查询图形信息
  275. queryGraph() {
  276. if (!this.curCategory.code) {
  277. return
  278. }
  279. this.selectCard = [];
  280. const pa = {
  281. Filters: `categoryId="${this.curCategory.code}"`,
  282. Orders: `${this.selVal} desc`
  283. }
  284. if (this.queryText.trim()) {
  285. pa.Filters += `;name contain "${this.queryText.trim()}"`
  286. }
  287. if (this.isPub) {
  288. queryPubGraph(pa).then(res => {
  289. this.cardList = res.content.map(t => {
  290. t.checked = false;
  291. return t;
  292. });
  293. this.queryText = '';
  294. })
  295. } else {
  296. pa.Filters += ";state=1"
  297. queryDraftsGraph(pa).then(res => {
  298. this.cardList = res.content.map(t => {
  299. t.checked = false;
  300. return t;
  301. });
  302. this.queryText = '';
  303. })
  304. }
  305. }
  306. },
  307. components: { Select, Button, leftAsideTree, Dropdown, topoImageCard, rename, move, deleteDialog },
  308. watch: {
  309. // 排序方式修改
  310. selVal(n, o) {
  311. if (n === o) return;
  312. this.selText = this.dataSelect.find(d => d.id === n).name;
  313. this.selectCard = [];
  314. this.queryGraph()
  315. }
  316. }
  317. };
  318. </script>
  319. <style lang="less" scoped>
  320. .home {
  321. width: 100%;
  322. height: 100%;
  323. .header {
  324. width: 100%;
  325. height: 60px;
  326. background: #f7f9fa;
  327. padding: 0 16px 0 16px;
  328. box-sizing: border-box;
  329. display: flex;
  330. align-items: center;
  331. justify-content: space-between;
  332. }
  333. .bodys {
  334. width: 100%;
  335. height: 100%;
  336. .main {
  337. width: 100%;
  338. height: 100%;
  339. background: #fff;
  340. padding: 5px 20px;
  341. box-sizing: border-box;
  342. .main-head {
  343. position: relative;
  344. width: 100%;
  345. height: 46px;
  346. margin-bottom: 5px;
  347. .showType {
  348. width: 100%;
  349. padding: 7px 0;
  350. display: flex;
  351. align-items: center;
  352. justify-content: space-between;
  353. /deep/
  354. .el-radio-button__orig-radio:checked
  355. + .el-radio-button__inner {
  356. color: #0091ff;
  357. border-color: #0091ff;
  358. background: #e1f2ff;
  359. }
  360. .head-right {
  361. display: flex;
  362. align-items: center;
  363. .Dropdown {
  364. min-width: 100px;
  365. margin-left: 20px;
  366. .drop-text {
  367. font-size: 14px;
  368. color: #1f2329;
  369. line-height: 16px;
  370. }
  371. }
  372. }
  373. }
  374. .showAction {
  375. background: #e1f2ff;
  376. border-radius: 4px;
  377. border: 1px solid #82c7fc;
  378. padding: 8px;
  379. span.sum {
  380. margin: 0 10px;
  381. color: #778089;
  382. }
  383. }
  384. }
  385. .main-body {
  386. display: flex;
  387. flex-wrap: wrap;
  388. height: calc(100% - 51px);
  389. &.no-data {
  390. justify-content: center;
  391. // align-items: center;
  392. }
  393. }
  394. }
  395. }
  396. .create-dialog {
  397. .dialog-bodys {
  398. width: 367px;
  399. margin: 0 auto;
  400. }
  401. }
  402. .create-dialog-inner {
  403. .inner-dialog-body {
  404. width: 100%;
  405. display: flex;
  406. .left {
  407. flex: 1;
  408. border-right: 1px solid #ccc;
  409. }
  410. }
  411. }
  412. }
  413. </style>