examine.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. <template>
  2. <div class="mainBox">
  3. <!--搜索功能 start------------------------------------------------------------>
  4. <div class="layerBox_search">
  5. <div class="layerBoxLine">
  6. <el-row>
  7. <el-col :span="8">
  8. <div class="searchBox">
  9. <div class="searchTitle">资讯题目:</div>
  10. <el-input placeholder="请输入资讯题目" autocomplete="off" v-model="getApiData.title" />
  11. </div>
  12. </el-col>
  13. <el-col :span="8">
  14. <div class="searchBox">
  15. <div class="searchTitle">栏目名称:</div>
  16. <el-input placeholder="请输入栏目名称" autocomplete="off" v-model="getApiData.category_name" />
  17. </div>
  18. </el-col>
  19. <el-col :span="8">
  20. <div class="searchBox">
  21. <div class="searchTitle">作者:</div>
  22. <el-input placeholder="请输入作者姓名" autocomplete="off" v-model="getApiData.author" />
  23. </div>
  24. </el-col>
  25. </el-row>
  26. </div>
  27. <div class="layerBoxLineTwo">
  28. <el-row>
  29. <el-col :span="8">
  30. <div class="searchBox">
  31. <div class="searchTitle">引用外链:</div>
  32. <el-select v-model="getApiData.islink" placeholder="请选择..">
  33. <el-option label="否" value="0"></el-option>
  34. <el-option label="是" value="1"></el-option>
  35. </el-select>
  36. </div>
  37. </el-col>
  38. <el-col :span="8">
  39. <div class="searchBox">
  40. <div class="searchTitle">资讯状态:</div>
  41. <el-select v-model="getApiData.status" placeholder="请选择..">
  42. <el-option label="待审核" value="0"></el-option>
  43. <el-option label="已拒绝" value="2"></el-option>
  44. </el-select>
  45. </div>
  46. </el-col>
  47. </el-row>
  48. </div>
  49. </div>
  50. <div class="layerBoxNoBg">
  51. <div>
  52. <!-- <el-button type="primary" @click="goCreat">发布资讯</el-button> -->
  53. </div>
  54. <div>
  55. <el-button @click="clearSearchList">重置</el-button>
  56. <el-button type="primary" @click="getData('search')">搜索</el-button>
  57. </div>
  58. </div>
  59. <!--搜索功能 end------------------------------------------------------------>
  60. <!--表格内容 start------------------------------------------------------------>
  61. <div class="layerBox">
  62. <tableTitle :name="tableDivTitle" />
  63. <el-row>
  64. <template>
  65. <el-table :data="tableData" style="width: 100%">
  66. <el-table-column fixed prop="id" label="编号" width="50"></el-table-column>
  67. <el-table-column prop="title" label="资讯题目" width=""></el-table-column>
  68. <el-table-column prop="category_name" label="栏目名称" width=""></el-table-column>
  69. <el-table-column prop="alias" label="展示名称" width="100"></el-table-column>
  70. <el-table-column prop="islink" label="是否引用外链" width=""></el-table-column>
  71. <el-table-column prop="linkurl" label="是否为原创" width="">
  72. <template slot-scope="scope">
  73. <span v-if="scope.row.is_original == 1">
  74. </span>
  75. <span v-if="scope.row.is_original == 0">
  76. </span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column prop="author" label="作者" width=""></el-table-column>
  80. <!-- <el-table-column prop="created_at" label="创建时间" width=""></el-table-column> -->
  81. <el-table-column prop="updated_at" label="修改时间" width=""></el-table-column>
  82. <el-table-column prop="status" label="审核状态" width="100">
  83. <template slot-scope="scope">
  84. <!-- <span v-if="scope.row.status==404">404</span>
  85. <el-switch
  86. v-else
  87. v-model="scope.row.status"
  88. :active-value="1"
  89. :inactive-value="0"
  90. @change="upRow(scope.row.id,scope.row.status)"
  91. ></el-switch> -->
  92. <span v-if="scope.row.status == 0">待审核</span>
  93. <span v-if="scope.row.status == 1">已审核</span>
  94. <span v-if="scope.row.status == 2">已拒绝</span>
  95. </template>
  96. </el-table-column>
  97. <el-table-column fixed="right" label="操作" width="360" header-align="center"
  98. v-if="creatNews_user_type == 10000">
  99. <template slot-scope="scope">
  100. <div class="listBtnBox">
  101. <div class="listMainBtn" @click="getUpRow(scope.row.id, tableData)"><i class="el-icon-check"></i>审核
  102. </div>
  103. <div class="listDeleteBtn" @click="deleteRow(scope.row.id, tableData)"><i
  104. class="el-icon-delete"></i>删除</div>
  105. <div class="listEditBtn" @click="goEdit(scope.row.id, tableData)"><i
  106. class="el-icon-edit-outline"></i>编辑</div>
  107. </div>
  108. </template>
  109. </el-table-column>
  110. <el-table-column fixed="right" label="操作" width="360" header-align="center"
  111. v-if="creatNews_user_type != 10000">
  112. <template slot-scope="scope">
  113. <div class="listBtnBox">
  114. <!-- <div class="listLinkBtn" @click="selectRow(scope.row.cat_arr_id, scope.row)"><i class="el-icon-full-screen"></i>站点选择</div>
  115. <div class="listMainBtn" @click="getUpRow(scope.row.id, tableData)" v-if="scope.row.status==0"><i class="el-icon-check"></i>审核</div>
  116. <div class="listUpBtn" @click="returnRow(scope.row.id, tableData)" v-else><i class="el-icon-refresh-right"></i>撤回</div> -->
  117. <div class="listDeleteBtn" @click="deleteRow(scope.row.id, tableData)"><i
  118. class="el-icon-delete"></i>删除</div>
  119. <div class="listEditBtn" @click="goEdit(scope.row.id, tableData)"><i
  120. class="el-icon-edit-outline"></i>编辑</div>
  121. </div>
  122. </template>
  123. </el-table-column>
  124. </el-table>
  125. </template>
  126. </el-row>
  127. </div>
  128. <!--分页 start------------------------------------------------------------>
  129. <div class="alignBox">
  130. <el-row>
  131. <el-col :span="24">
  132. <el-pagination @size-change="handleSizeChange" :current-page="getApiData.page"
  133. @current-change="handleCurrentChange" :page-size="10" layout="total, prev, pager, next, jumper"
  134. :total="allCount"></el-pagination>
  135. </el-col>
  136. </el-row>
  137. </div>
  138. <!--分页 end------------------------------------------------------------>
  139. <!--表格内容 end------------------------------------------------------------>
  140. <!--弹出框1:外部表单弹出框 start------------------------------------------------------------>
  141. <el-dialog title="请输入驳回理由" :visible.sync="examineWindow" :close-on-click-modal="false">
  142. <el-form :model="form" ref="form" :rules="formRules" label-position="left">
  143. <div class="formDiv">
  144. <el-form-item label="驳回原因:" :label-width="formLabelWidth" prop="reason" class="custom-align-right">
  145. <el-input type="textarea" v-model="form.reason" class="custom-textarea" placeholder="请输入驳回原因"
  146. :rows="3"></el-input>
  147. </el-form-item>
  148. </div>
  149. </el-form>
  150. <div slot="footer" class="dialog-footer">
  151. <div>
  152. <el-button type="info" @click="examineWindow = false">取消</el-button>
  153. <el-button type="primary" @click="examineToServe">确定</el-button>
  154. </div>
  155. </div>
  156. </el-dialog>
  157. <!--弹出框1:外部表单弹出框 end------------------------------------------------------------>
  158. <!--弹出框2:选择要发布的网站 start------------------------------------------------------------>
  159. <el-dialog title="请选择不要发布的网站" :visible.sync="selectStatusWindow" :close-on-click-modal="false">
  160. <el-form label-position="left">
  161. <div class="formDiv">
  162. <el-table v-loading="loading" ref="multipleTable" :data="webSiteData" tooltip-effect="dark"
  163. style="width: 100%" @selection-change="handleSelectionChange">
  164. <el-table-column type="selection" width="55"></el-table-column>
  165. <el-table-column prop="website_id" label="网站id"></el-table-column>
  166. <el-table-column prop="website_name" label="网站名称"></el-table-column>
  167. </el-table>
  168. </div>
  169. </el-form>
  170. <div slot="footer" class="dialog-footer">
  171. <div>
  172. <el-button type="info" @click="selectStatusWindow = false">取消</el-button>
  173. <el-button type="primary" @click="selectWebSiteToServe">确定</el-button>
  174. </div>
  175. </div>
  176. </el-dialog>
  177. <!--弹出框2:选择要发布的网站 end------------------------------------------------------------>
  178. </div>
  179. </template>
  180. <script>
  181. //表格标题
  182. import tableTitle from './components/tableTitle';
  183. //引入公用样式
  184. import '@/styles/global.less';
  185. //获得用户身份
  186. import { getUseType } from '@/utils/auth'
  187. export default {
  188. components: {
  189. tableTitle,//表格标题
  190. },
  191. data() {
  192. //0.全局操作 start ------------------------------------------------------------>
  193. let self = this;
  194. //表单验证
  195. const validateEmpty = (rule, value, callback) => {
  196. if (value == '') {
  197. callback(new Error('该项不能为空!'))
  198. } else {
  199. callback()
  200. }
  201. }
  202. //0.全局操作 end ------------------------------------------------------------>
  203. return {
  204. //1.列表和分页相关 start ------------------------------------------------------------>
  205. tableDivTitle: "资讯列表",
  206. creatNews_user_type: 0,//用户类型
  207. tableData: [],//内容
  208. webSiteData: [],//可选网站列表
  209. editId: 0,//要修改的网站id
  210. editStatus: 0,//要修改的网站状态
  211. selectStatusWindow: false,//反选窗口
  212. examineWindow: false,//审核窗口
  213. formLabelWidth: "120px",//表单label宽度
  214. getApiData: {
  215. title: "",//标题
  216. category_name: "",//导航池id
  217. author: "",//作者
  218. islink: "",//是否使用外链
  219. status: "",//资讯状态
  220. status1: "[0,2]", //默认传递 - 如果不为空,表示获取所有未审核与已拒绝的
  221. page: 1,//当前是第几页
  222. pageSize: 10,//一共多少条
  223. },
  224. //提交驳回
  225. form: {
  226. reason: ""
  227. },
  228. //选择要发布的网站
  229. webSiteForm: {
  230. ignore_ids: []
  231. },
  232. ids: [],//待选网站列表
  233. loading: false,//loading
  234. formRules: {
  235. //导航池名称不能为空
  236. reason: [{ required: true, trigger: 'blur', validator: validateEmpty }],
  237. },
  238. allCount: 0,//总条数
  239. //分页相关 end ------------------------------------------------------------>
  240. }
  241. },
  242. methods: {
  243. //1.列表和分页相关 start ------------------------------------------------------------>
  244. //1.1 开始请求列表信息方法
  245. getData(type) {
  246. if (type == "search") {
  247. this.getApiData.page = 1;
  248. }
  249. this.$store.dispatch('news/getArticleList', this.getApiData).then(res => {
  250. //格式化:islink=0为不使用外面 islink=1为使用外链
  251. //status=1为显示 status=2为不显示
  252. let data = [];
  253. for (let item of res.data.rows) {
  254. // if(item.status==0){item.status="隐藏"}
  255. // if(item.status==1){item.status="显示"}
  256. // if(item.status==404){item.status="已删除"}
  257. if (item.islink == 0) { item.islink = "否" }
  258. if (item.islink == 1) { item.islink = "是" }
  259. data.push(item)
  260. }
  261. this.tableData = res.data.rows; //给与内容
  262. this.allCount = res.data.count; //给与总条数
  263. }).catch(() => {
  264. this.$message({
  265. type: 'warning',
  266. message: '网络错误,请重试!'
  267. });
  268. })
  269. },
  270. //1.2 删除内容
  271. deleteRow(id) {
  272. this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
  273. confirmButtonText: '确定',
  274. cancelButtonText: '取消',
  275. type: 'warning'
  276. }).then(() => {
  277. console.log("当前删除:" + id)
  278. this.$store.dispatch('news/delArticle', { id: id }).then(res => {
  279. this.getData();
  280. this.$message({
  281. type: 'success',
  282. message: '删除成功!'
  283. });
  284. })
  285. })
  286. },
  287. //1.3 撤回审核
  288. returnRow(id) {
  289. this.$confirm('确定要撤回吗?', '提示', {
  290. confirmButtonText: '撤回',
  291. cancelButtonText: '取消',
  292. type: 'warning'
  293. }).then(() => {
  294. //撤回,把文章状态修改为0,重新进行审核
  295. this.upRow(id, 0)
  296. })
  297. },
  298. //1.4 审核温江
  299. getUpRow(id) {
  300. //设置待审核的id
  301. this.editId = id;
  302. console.log(id)
  303. this.$confirm('将此文章通过审核吗?', '提示', {
  304. confirmButtonText: '通过',
  305. cancelButtonText: '拒绝',
  306. type: 'warning'
  307. }).then(() => {
  308. this.upRow(id, 1)
  309. }).catch(() => {
  310. //输入驳回理由
  311. console.log("驳回")
  312. this.examineWindow = true;
  313. })
  314. },
  315. //1.5 修改文章状态
  316. upRow(id, status) {
  317. let data = {
  318. id: id,
  319. status: status
  320. }
  321. this.$store.dispatch('news/upArticleStatus', data).then(res => {
  322. if (res.code == 200) {
  323. this.$message({
  324. type: 'success',
  325. message: '操作成功!'
  326. });
  327. this.getData();
  328. }
  329. })
  330. },
  331. //提交驳回内容
  332. examineToServe(id) {
  333. this.$refs.form.validate(valid => {
  334. if (valid) {
  335. let data = {
  336. id: this.editId,
  337. status: 2,//驳回status
  338. reason: this.form.reason
  339. }
  340. this.$store.dispatch('news/upArticleStatus', data).then(res => {
  341. if (res.code == 200) {
  342. this.$message({
  343. type: 'success',
  344. message: '操作成功!'
  345. });
  346. this.getData();
  347. this.form.reason = "";//清空上一次的输入
  348. this.examineWindow = false;
  349. }
  350. })
  351. } else {
  352. this.$message.error("驳回理由不能为空!")
  353. }
  354. })
  355. },
  356. //1.6 打开反选窗口
  357. selectRow(cid, row) {
  358. console.log(row)
  359. this.selectStatusWindow = true;
  360. //给与编辑的id
  361. this.editId = row.id;
  362. //给与编辑的状态
  363. this.editStatus = row.status;
  364. //把cid转换成数组,然后取出最后一位
  365. let cidArr = cid.replace(/[\[\]]/g, '').split(',');
  366. // 获取数组的最后一个元素
  367. let cidLast = cidArr[cidArr.length - 1];
  368. this.getWebsiteNavPoolSite(cidLast, row)
  369. },
  370. //1.7 列表内容分页
  371. //直接跳转
  372. handleSizeChange(val) {
  373. this.getApiData.page = val;
  374. this.getData();
  375. },
  376. //1.8 点击分页
  377. handleCurrentChange(val) {
  378. this.getApiData.page = val;
  379. this.getData();
  380. },
  381. //1.9 重置按钮
  382. clearSearchList() {
  383. this.tableData = [];
  384. this.getApiData.title = "";
  385. this.getApiData.category_name = "";
  386. this.getApiData.author = "";
  387. this.getApiData.islink = "";
  388. this.getApiData.status = "";
  389. this.getApiData.page = 1;
  390. this.getApiData.pageSize = 10;
  391. this.getData();
  392. },
  393. //1.10 获取可选网站列表
  394. getWebsiteNavPoolSite(cid, row) {
  395. this.loading = true;
  396. let ignoreIds = JSON.parse(row.ignore_ids);
  397. this.webSiteData = [];
  398. this.$store.dispatch('news/getWebsiteNavPoolSite', { category_id: cid }).then(res => {
  399. // for(let item of res.data){
  400. // if(item.website_name!=null){
  401. // this.webSiteData.push(item)
  402. // }
  403. // }
  404. this.webSiteData = res.data;
  405. //延迟一会返显,否则可能显示不了
  406. if (res.data.length > 0 && ignoreIds != null) {
  407. setTimeout(() => {
  408. for (let index in this.webSiteData) {
  409. if (ignoreIds.includes(this.webSiteData[index].website_id)) {
  410. console.log(1234656)
  411. console.log(index)
  412. //调用回显方法
  413. this.toggleSelection([this.webSiteData[index]])
  414. }
  415. }
  416. this.loading = false;
  417. }, 500)
  418. } else {
  419. this.loading = false;
  420. }
  421. })
  422. },
  423. //1.11 提交选择的网站列表
  424. selectWebSiteToServe(id) {
  425. let ids = [];
  426. for (let item of this.ids) {
  427. ids.push(item.website_id)
  428. }
  429. //把数组转换为字符串
  430. //let idsStr = ids.join(',');
  431. //把数组转换为字符串
  432. let idsStr = JSON.stringify(ids);
  433. if (idsStr.length == 0) {
  434. this.$message.error("至少需要选择一个网站!")
  435. return;
  436. } else {
  437. let data = {
  438. id: this.editId,
  439. ignore_ids: idsStr,
  440. status: this.editStatus
  441. }
  442. this.$store.dispatch('news/upArticleStatus', data).then(res => {
  443. console.log(res)
  444. if (res.code == 200) {
  445. this.$message({
  446. type: 'success',
  447. message: '资讯绑定网站成功!'
  448. });
  449. this.selectStatusWindow = false;
  450. this.getData();
  451. } else {
  452. this.$message.error(res.data.msg)
  453. }
  454. })
  455. }
  456. },
  457. //把选择的网站保存到待选择的网站列表
  458. handleSelectionChange(val) {
  459. console.log(val)
  460. this.ids = val;
  461. },
  462. //回显 选中的方法
  463. toggleSelection(rows) {
  464. console.log(rows)
  465. if (rows) {
  466. rows.forEach(row => {
  467. this.$refs.multipleTable.toggleRowSelection(row);
  468. });
  469. } else {
  470. this.$refs.multipleTable.clearSelection();
  471. }
  472. },
  473. //列表和分页相关 end ------------------------------------------------------------>
  474. //2.添加新闻 start ------------------------------------------------------------>
  475. //跳转到资讯发布页面
  476. goCreat() {
  477. this.$router.push({
  478. path: '/creatNews',
  479. });
  480. },
  481. goEdit(id) {
  482. let data = {
  483. id: id,
  484. to: "examine"
  485. }
  486. this.$router.push({
  487. path: '/creatNews',
  488. query: data
  489. });
  490. }
  491. //添加新闻 end ------------------------------------------------------------>
  492. },
  493. mounted() {
  494. this.creatNews_user_type = getUseType()
  495. //1.获得初始数据
  496. this.getData();
  497. }
  498. }
  499. </script>
  500. <style scoped lang="less"></style>