surveyList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. <template>
  2. <!-- 广告位管理 -->
  3. <div>
  4. <!-- 头部搜索框部分 -->
  5. <div class="title">
  6. <el-row>
  7. <el-col :span="8" class="left">
  8. <div class="searchBox">
  9. <div class="searchTitle">投票名称</div>
  10. <el-input v-model="tabbarName" class="input" placeholder="请输入投票名称" :maxlength="10"></el-input>
  11. </div>
  12. </el-col>
  13. <el-col :span="8" class="left">
  14. <div class="searchBox">
  15. <div class="searchTitle">投票类型</div>
  16. <el-select v-model="typeid" placeholder="请选择投票类型...">
  17. <el-option label="单选" value="0"></el-option>
  18. <el-option label="多选" value="1"></el-option>
  19. </el-select>
  20. </div>
  21. </el-col>
  22. <el-col :span="8" class="left">
  23. <div class="searchBox">
  24. <div class="searchTitle">是否开启</div>
  25. <el-select v-model="status" placeholder="请选择是否开启...">
  26. <el-option label="是" value="1"></el-option>
  27. <el-option label="否" value="0"></el-option>
  28. </el-select>
  29. </div>
  30. </el-col>
  31. </el-row>
  32. <el-row>
  33. <el-col :span="8" class="right">
  34. <div class="btnList">
  35. <button class="search" @click="goSearch">搜索</button>
  36. <button class="reset" @click="goReset">重置</button>
  37. </div>
  38. </el-col>
  39. </el-row>
  40. </div>
  41. <!--表格内容 start------------------------------------------------------------>
  42. <div class="layerBox">
  43. <tableTitle :name="tableDivTitle" />
  44. <el-row>
  45. <template>
  46. <el-table class="my-table" :data="tableData" style="width: 100%">
  47. <el-table-column type="index" :index="indexMethod" label="编号" width="90">
  48. </el-table-column>
  49. <el-table-column prop="survey_name" label="投票名称" width="500">
  50. </el-table-column>
  51. <el-table-column prop="survey_type" label="投票类型" width="100" >
  52. <template slot-scope="scope">
  53. <span v-if="scope.row.survey_type==1">
  54. 多选
  55. </span>
  56. <span v-if="scope.row.survey_type==0">
  57. 单选
  58. </span>
  59. </template>
  60. </el-table-column>
  61. <el-table-column prop="is_survey" label="是否开启" width="100">
  62. <template slot-scope="scope">
  63. <span v-if="scope.row.is_survey==1">
  64. </span>
  65. <span v-if="scope.row.is_survey==0">
  66. </span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column prop="created_at" label="添加时间" width="">
  70. </el-table-column>
  71. <el-table-column prop="updated_at" label="修改时间" width="">
  72. </el-table-column>
  73. <el-table-column fixed="right" label="操作" width="">
  74. <template slot-scope="scope">
  75. <div class="listBtnBox">
  76. <div class="listLookBtn" @click="goLook(scope.row.survey_id)">
  77. <i class="el-icon-view"></i>
  78. 查看
  79. </div>
  80. </div>
  81. </template>
  82. </el-table-column>
  83. </el-table>
  84. </template>
  85. </el-row>
  86. </div>
  87. <!--分页 start------------------------------------------------------------>
  88. <div class="alignBox">
  89. <el-row>
  90. <el-col :span="24">
  91. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
  92. :current-page="page" :page-size="pageSize" layout="total, prev, pager, next, jumper"
  93. :total="total">
  94. </el-pagination>
  95. </el-col>
  96. </el-row>
  97. </div>
  98. <!--分页 end------------------------------------------------------------>
  99. <!--表格内容 end------------------------------------------------------------>
  100. <!-- 弹出框 编辑 start----------------------------------------------------------->
  101. <el-dialog :title="dialogName" :visible.sync="dialogTableVisible" width="50%" top="8vh">
  102. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
  103. <p style="font-size: 16px;"><b>投票名称:{{sur_name}}</b></p>
  104. <el-table :data="choose" style="width: 100%" height="250" row-key="id" border lazy :load="load":tree-props="{children: 'children', hasChildren: 'hasChildren'}">
  105. <el-table-column type="index" :index="indexMethod"></el-table-column>
  106. <el-table-column prop="choice_name" label="选项名称"></el-table-column>
  107. <el-table-column prop="results" label="投票结果" width="180"></el-table-column>
  108. </el-table>
  109. <p style="font-size: 16px;text-align: right;margin-right: 80px;">总计:{{ total_num }}</p>
  110. <div class="dialogBtn">
  111. <el-button type="primary" @click="cancelForm">确定</el-button>
  112. </div>
  113. </el-form>
  114. </el-dialog>
  115. <!-- 弹出框 编辑 end----------------------------------------------------------->
  116. </div>
  117. </template>
  118. <script>
  119. //表格标题
  120. import tableTitle from './components/tableTitle.vue';
  121. //引入公用样式
  122. import '@/styles/global.less';
  123. // import { getSurveyList,getSurveyInfo } from '@/api/news'
  124. export default {
  125. components: {
  126. tableTitle,//表格标题-
  127. },
  128. data() {
  129. return {
  130. typeid: "",
  131. status: "",
  132. tableDataInfo: [],
  133. tableData1: [],
  134. tableDivTitle: "投票列表", //列表标题
  135. dialogTableVisible: false, //编辑弹框
  136. dialogName: '编辑', //编辑弹窗名称
  137. disabled: false, //禁用
  138. tableData: [],//表格数据
  139. tableDataInfo: [],//弹框数据
  140. choose: [], //选择的数据
  141. choose_other: [], //其他数据
  142. // choose_others: [], //其他选择的数据
  143. activeid: "", //活动id
  144. // 分页相关
  145. total_num: 0, //投票总数
  146. sur_name: "", //投票名称
  147. // survey_type: "", //投票类型
  148. // is_survey: "", //是否开启
  149. page: 1,
  150. pageSize: 10,
  151. total: 0,
  152. tabbarName: '', //底部导航名称
  153. ruleForm: {
  154. tabbarName: '', //底部导航名称
  155. },
  156. rules: {
  157. tabbarName: [{ required: true, message:"课题分类名称不能为空"}],
  158. }
  159. }
  160. },
  161. methods: {
  162. //1.1 开始请求列表信息方法
  163. getData(){
  164. let formData = {
  165. page: this.page,
  166. pageSize: this.pageSize,
  167. survey_name:this.tabbarName,
  168. survey_type:this.typeid,
  169. is_survey:this.status
  170. }
  171. this.$store.dispatch('news/getSurveyList', formData).then(res => {
  172. if (res.code == 200) {
  173. this.tableData = res.data.rows;
  174. this.total = res.data.count;
  175. }else{
  176. this.$message({
  177. type: 'error',
  178. message: '获取失败!'
  179. })
  180. }
  181. }).catch(() => {
  182. this.$message({
  183. type: 'info',
  184. message: '暂无记录!'
  185. });
  186. })
  187. },
  188. //1.2 列表内容分页
  189. //直接跳转
  190. handleSizeChange(val) {
  191. this.page = val;
  192. this.getData();
  193. },
  194. //1.3 点击分页
  195. handleCurrentChange(val) {
  196. this.page = val;
  197. this.getData();
  198. },
  199. // 1.6 搜索按钮
  200. goSearch() {
  201. this.getData()
  202. },
  203. //1.7 重置按钮
  204. goReset() {
  205. this.page = 1
  206. this.tabbarName = ""
  207. this.typeid = ""
  208. this.status = ""
  209. this.getData()
  210. },
  211. //取消添加或编辑
  212. cancelForm() {
  213. this.dialogTableVisible = false
  214. },
  215. //列表和分页相关 end ------------------------------------------------------------>
  216. // //1.9 查看
  217. goLook(id, val) {
  218. this.dialogName = '查看'
  219. this.activeid = id
  220. this.dialogTableVisible = true
  221. this.disabled=true
  222. //数据回显\
  223. this.getSurveyInfo(id);
  224. // this.ruleForm.tabbarName = val.survey_name //课题分类名称
  225. },
  226. //1.7 添加
  227. addTopicClass() {
  228. this.dialogTableVisible = true
  229. this.dialogName = "添加"
  230. this.disabled=false
  231. //添加时清空回显回来的数据
  232. this.ruleForm.tabbarName = '' //课题分类名称
  233. },
  234. getSurveyInfo(sur_id) {
  235. if (sur_id !== '') {
  236. let data = { sur_id: sur_id }
  237. this.$store.dispatch('news/getSurveyInfo', data).then(res => {
  238. if(res.code==200){
  239. this.sur_name = res.data.choose[0].survey_name
  240. this.total_num = res.data.total
  241. if(res.data.choose.length>0){
  242. this.choose = res.data.choose
  243. }
  244. // console.log(res.data.other.id);
  245. }
  246. }).catch(() => {
  247. this.$message({
  248. type: 'info',
  249. message: '网络错误,请重试!'
  250. });
  251. })
  252. }
  253. },
  254. indexMethod(index) {
  255. return index +1;
  256. },
  257. load(tree, treeNode, resolve) {
  258. setTimeout(() => {
  259. // 初始化一个空数组来存储所有的 children 数据
  260. let allChildren = [];
  261. // 遍历 choose 数组
  262. this.choose.forEach(item => {
  263. if (item.children && item.children.length > 0) {
  264. // 如果 item 有 children 属性且不为空,则将其合并到 allChildren 数组中
  265. allChildren = allChildren.concat(item.children);
  266. }
  267. });
  268. // 将 allChildren 数组传递给 resolve 函数
  269. resolve(allChildren);
  270. }, 1000);
  271. }
  272. },
  273. mounted() {
  274. this.getData()
  275. },
  276. }
  277. </script>
  278. <style scoped lang="less">
  279. input[aria-hidden=true] {
  280. display: none !important;
  281. }
  282. // 提示信息
  283. .tips {
  284. margin: 30px;
  285. background-color: #e9ecf9;
  286. border-radius: 11px;
  287. .tipsIcon {
  288. margin: 10px 15px;
  289. display: inline-block;
  290. width: 24px;
  291. height: 24px;
  292. background: url("../../assets/advertise/Info Circle.png") no-repeat;
  293. vertical-align: middle;
  294. }
  295. .tipsText {
  296. font-size: 14px;
  297. color: #666666;
  298. }
  299. }
  300. // 头部
  301. .title {
  302. margin: 30px 30px 20px 30px;
  303. padding: 30px 30px 40px 30px;
  304. background-color: #fff;
  305. border-radius: 20px 20px 20px 20px;
  306. border: 1px solid #E9EDF7;
  307. .left {
  308. float: left;
  309. }
  310. .right {
  311. float: right;
  312. }
  313. .searchBox {
  314. ::v-deep .el-input {
  315. position: relative;
  316. font-size: 14px;
  317. display: inline-block;
  318. width: 80%;
  319. }
  320. .searchTitle {
  321. padding-bottom: 10px;
  322. font-family: Microsoft YaHei, Microsoft YaHei;
  323. font-weight: 400;
  324. font-size: 14px;
  325. color: #999999;
  326. line-height: 16px;
  327. }
  328. .el-select {
  329. width: 100%;
  330. display: inline-block;
  331. position: relative;
  332. }
  333. }
  334. .btnList {
  335. float: right;
  336. padding-top: 28px;
  337. button {
  338. height: 38px;
  339. border: none;
  340. border-radius: 8px;
  341. padding: 0 30px;
  342. }
  343. .search {
  344. background-color: #5570f1;
  345. color: #fff;
  346. margin-right: 20px;
  347. }
  348. .reset {
  349. font-family: Microsoft YaHei, Microsoft YaHei;
  350. font-weight: 400;
  351. font-size: 16px;
  352. color: #333333;
  353. background: #F5F7FB;
  354. border-radius: 8px 8px 8px 8px;
  355. border: 1px solid rgba(85, 112, 241, 0.11);
  356. }
  357. }
  358. }
  359. .layerBox {
  360. padding: 30px 20px;
  361. position: relative;
  362. .btn {
  363. margin-bottom: 20px;
  364. position: absolute;
  365. top: 30px;
  366. right: 20px;
  367. height: 38px;
  368. color: #fff;
  369. background-color: #5570f1;
  370. border: none;
  371. border-radius: 8px;
  372. padding: 8px 28px 9px;
  373. box-sizing: border-box;
  374. }
  375. .listBtnBox {
  376. justify-content: left;
  377. }
  378. .listDeleteBtn,
  379. .listEditBtn,
  380. .listLookBtn {
  381. margin-left: 0px;
  382. padding-left: 0px;
  383. margin-right: 20px;
  384. width: 76px;
  385. height: 36px;
  386. line-height: 36px;
  387. }
  388. .listLookBtn {
  389. text-align: center;
  390. border-radius: 8px;
  391. cursor: pointer;
  392. color: #55b5f1;
  393. background-color: rgba(85, 181, 241, 0.16);
  394. >i {
  395. padding-right: 8px;
  396. }
  397. }
  398. ::v-deep .el-form-item {
  399. margin-bottom: 50px;
  400. }
  401. ::v-deep .el-select {
  402. width: 100%;
  403. }
  404. ::v-deep .el-input--medium,
  405. ::v-deep .el-form-item__label {
  406. line-height: 36px;
  407. font-size: 16px;
  408. }
  409. }
  410. // 弹出层内容
  411. .dialogText {
  412. margin: 0 7px 0 3px;
  413. padding-bottom: 1px;
  414. padding: 30px 60px 1px 20px;
  415. background-color: #f5f7fb;
  416. .adImage {
  417. width: 140px;
  418. height: 140px;
  419. line-height: 210px;
  420. border-radius: 12px;
  421. border: 1px solid rgba(85, 112, 241, 0.11);
  422. img {
  423. width: 140px;
  424. height: 80px;
  425. }
  426. }
  427. ::v-deep .avatar {
  428. width: 140px;
  429. height: auto;
  430. }
  431. .price {
  432. ::v-deep .el-input {
  433. width: 29%;
  434. }
  435. }
  436. .example {
  437. font-family: Microsoft YaHei;
  438. color: #5570F1;
  439. }
  440. .el_btnList {
  441. margin-right: 15px;
  442. margin-top: 20px;
  443. }
  444. //日期时间选择器的宽
  445. ::v-deep .el-date-editor.el-input {
  446. width: 48%;
  447. }
  448. ::v-deep .el-button+.el-button {
  449. margin-left: 0px;
  450. }
  451. ::v-deep .el-select {
  452. width: 100%;
  453. }
  454. ::v-deep .el-form-item {
  455. margin-bottom: 50px;
  456. }
  457. }
  458. // 弹出层按钮
  459. .dialogBtn {
  460. text-align: center;
  461. margin: 50px auto 20px;
  462. button {
  463. width: 184px;
  464. padding: 16px;
  465. font-family: Microsoft YaHei, Microsoft YaHei;
  466. font-weight: 400;
  467. font-size: 20px;
  468. border: none;
  469. border-radius: 12px 12px 12px 12px;
  470. }
  471. // 取消
  472. .cancel {
  473. color: #333333;
  474. background-color: #f5f7fb;
  475. border: 2px solid rgba(85, 112, 241, 0.11);
  476. }
  477. // 提交
  478. .submit {
  479. color: #fff;
  480. background-color: #5570F1;
  481. margin-left: 40px;
  482. }
  483. }
  484. //审核弹出框
  485. .radioGroup {
  486. ::v-deep .el-form-item {
  487. margin-top: 40px;
  488. margin-bottom: 0;
  489. }
  490. }
  491. .graph {
  492. background-color: #f5f7fb;
  493. padding: 60px 100px;
  494. overflow: hidden;
  495. li {
  496. float: left;
  497. }
  498. >li:first-child {
  499. margin-right: 100px;
  500. }
  501. }
  502. .dialog-footer {
  503. margin: 0 auto;
  504. }
  505. </style>