index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. <template>
  2. <div class="common-container my-open-img">
  3. <TitleBar></TitleBar>
  4. <div class="main-container">
  5. <div class="search-container TableSelectMain">
  6. <el-form class="table-select-main" :model="searchForm" label-position="left">
  7. <el-row :gutter="15">
  8. <el-col :span="4">
  9. <el-form-item>
  10. <el-input placeholder="请输入标题" v-model="searchForm.title"></el-input>
  11. </el-form-item>
  12. </el-col>
  13. <el-col :span="4">
  14. <el-form-item>
  15. <el-input placeholder="请输入专家" v-model="searchForm.userName"></el-input>
  16. </el-form-item>
  17. </el-col>
  18. <el-col :span="4">
  19. <el-form-item>
  20. <BrandList @brandChange="brandChange" ref="brand"></BrandList>
  21. </el-form-item>
  22. </el-col>
  23. <el-col :span="4" v-if="show">
  24. <el-form-item>
  25. <el-select placeholder="启用状态" v-model="searchForm.statuz" clearable>
  26. <el-option label="是" :value="1"></el-option>
  27. <el-option label="否" :value="0"></el-option>
  28. </el-select>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :span="4">
  32. <el-form-item>
  33. <el-select placeholder="审核状态" v-model="searchForm.examineFlag" clearable>
  34. <el-option label="未审核" :value="0"></el-option>
  35. <el-option label="审核通过" :value="1"></el-option>
  36. <el-option label="驳回" :value="2"></el-option>
  37. </el-select>
  38. </el-form-item>
  39. </el-col>
  40. <el-col :span="4">
  41. <el-form-item>
  42. <el-button type="primary" plain round @click="query">查询</el-button>
  43. <el-button type="primary" plain round @click="reset">重置</el-button>
  44. </el-form-item>
  45. </el-col>
  46. <el-col :span="24">
  47. <el-form-item>
  48. <el-button type="primary" round plain icon="el-icon-plus" @click="create(null)" v-if="show">新建</el-button>
  49. <el-button type="primary" plain round v-if="show" @click="batchPutaway">批量开启</el-button>
  50. <el-button type="primary" plain round v-if="show" @click="batchUnshelve">批量关闭</el-button>
  51. <el-button type="primary" plain round v-if="show" @click="deleteData(ids, 'batch')">批量删除</el-button>
  52. </el-form-item>
  53. </el-col>
  54. </el-row>
  55. </el-form>
  56. </div>
  57. <div class="SearchTitle">
  58. 已选择
  59. <span class="subject-color">{{ ids.length }}</span> 项
  60. </div>
  61. <div class="MaintenanceTable">
  62. <el-table ref="multipleTable" :data="tableData" style="width: 100%" tooltip-effect="dark" @selection-change="selectionChange" class="OutTable" border v-loading="listLoading">
  63. <el-table-column type="selection"></el-table-column>
  64. <el-table-column prop="title" label="标题" :show-overflow-tooltip="true"></el-table-column>
  65. <el-table-column prop="userName" label="专家" :show-overflow-tooltip="true"></el-table-column>
  66. <el-table-column prop="expression" label="问题现象" :show-overflow-tooltip="true"></el-table-column>
  67. <el-table-column prop="solution" label="解决方法" :show-overflow-tooltip="true"></el-table-column>
  68. <el-table-column prop="imgs" label="图片">
  69. <template slot-scope="scope">
  70. <span v-if="scope.row.imgs && scope.row.imgs.length > 0">
  71. <el-image
  72. :src="scope.row.imgs[0] | pathPipe"
  73. style="width:64px;height:64px;cursor:pointer"
  74. :preview-src-list="[scope.row.imgs[0]]">
  75. </el-image>
  76. </span>
  77. <span v-else>-无-</span>
  78. </template>
  79. </el-table-column>
  80. <el-table-column prop="brandName" label="电梯品牌" :show-overflow-tooltip="true"></el-table-column>
  81. <el-table-column prop="browseNum" label="浏览量">
  82. <template slot-scope="scope">
  83. <span>{{scope.row.browseNum || 0}}</span>
  84. </template>
  85. </el-table-column>
  86. <el-table-column prop="tipNum" label="打赏量">
  87. <template slot-scope="scope">
  88. <span>{{scope.row.tipNum || 0}}</span>
  89. </template>
  90. </el-table-column>
  91. <el-table-column prop="examineFlag" label="审核状态">
  92. <template slot-scope="scope">
  93. <span class="warn" v-show="scope.row.examineFlag == 0">未审核</span>
  94. <span class="success" v-show="scope.row.examineFlag == 1">审核通过</span>
  95. <RejectReason :content="scope.row.notExamineReason" v-show="scope.row.examineFlag == 2"></RejectReason>
  96. </template>
  97. </el-table-column>
  98. <el-table-column prop="hotFlag" label="置顶" min-width="110px;" v-if="show">
  99. <template slot-scope="scope">
  100. <el-switch v-model="scope.row.hotFlag" active-text="开" inactive-text="关" :active-value="1" :inactive-value="0" :disabled="scope.row.examineFlag !==1" @change="switchShow(scope.row.hotFlag, scope.row.id)"></el-switch>
  101. </template>
  102. </el-table-column>
  103. <el-table-column prop="statuz" label="启用状态" min-width="110px;" v-if="show">
  104. <template slot-scope="scope">
  105. <el-switch v-model="scope.row.statuz" active-text="开" inactive-text="关" :active-value="1" :inactive-value="0" :disabled="scope.row.examineFlag !==1" @change="switchChange(scope.row.statuz, scope.row.id)"></el-switch>
  106. </template>
  107. </el-table-column>
  108. <el-table-column label="操作" min-width="300px;">
  109. <template slot-scope="scope">
  110. <el-button size="mini" type="primary" plain round @click="deleteData(scope.row.id)" v-if="show">删除</el-button>
  111. <el-button size="mini" type="primary" plain round :disabled="scope.row.examineFlag === 1" @click="edit(scope.row)" v-if="show">编辑</el-button>
  112. <!-- <el-button
  113. size="mini"
  114. type="primary"
  115. plain
  116. round
  117. v-show="stickShow"
  118. v-if="show"
  119. @click="toTop(scope.row.id, scope.row.hotFlag)"
  120. >{{ scope.row.hotFlag === 1 ? '取消置顶' : '置顶' }}</el-button>-->
  121. <el-button size="mini" type="primary" plain round @click="showDetailsDialog(scope.row)">详情</el-button>
  122. <el-button type="primary" plain round size="mini" v-if="!show" @click="pass(scope.row.id)">通过</el-button>
  123. <el-button type="primary" plain round size="mini" v-if="!show" @click="rejectShow(scope.row.id)">驳回</el-button>
  124. </template>
  125. </el-table-column>
  126. </el-table>
  127. <div class="pagenation">
  128. <PageComponent :total="total" @pagination="handlePagination" :pageSize.sync="page.pageSize" :pageNum.sync="page.pageNum"></PageComponent>
  129. </div>
  130. </div>
  131. </div>
  132. <!-- 添加与编辑弹层 -->
  133. <AddEditDialog @queryListData="queryListData" ref="addEditDialog"></AddEditDialog>
  134. <!-- 详情弹层 -->
  135. <DetailsDialog @queryListData="queryListData" ref="detailsDialog"></DetailsDialog>
  136. <!-- 驳回弹窗 -->
  137. <RejectDialog @isReject="isReject" ref="regectDialog"></RejectDialog>
  138. </div>
  139. </template>
  140. <script>
  141. import TitleBar from '@/apps/mobile/components/common/TitleBar';
  142. import AddEditDialog from './components/addEditDialog';
  143. import DetailsDialog from './components/detailsDialog';
  144. import RejectDialog from '@/apps/mobile/components/reject/index';
  145. import RejectReason from '@/apps/mobile/components/ReasonForRejection/index';
  146. import { queryPage, removeData, editData, toUp, useBath, noUseBath, examine } from '@/apps/mobile/api/question/index';
  147. import { queryAllBrand } from '@/apps/mobile/api/databank/index';
  148. import BrandList from '@/apps/mobile/components/brandLongSerch/index'; // 电梯品牌远程搜索
  149. export default {
  150. components: {
  151. TitleBar,
  152. AddEditDialog,
  153. DetailsDialog,
  154. RejectDialog,
  155. RejectReason,
  156. BrandList,
  157. },
  158. data() {
  159. return {
  160. searchForm: {},
  161. tableData: [],
  162. page: {
  163. pageNum: 1,
  164. pageSize: 5,
  165. },
  166. total: 0,
  167. listLoading: false, // table是否展示loading
  168. ids: [], // 选中的列
  169. stickShow: true,
  170. show: 1, // 控制页面按钮的显隐,进入审批页面会变为0
  171. allBrandList: [],
  172. selection: [],
  173. };
  174. },
  175. created() {
  176. this.$nextTick(() => {
  177. this.queryListData();
  178. });
  179. },
  180. methods: {
  181. /**
  182. * 新增
  183. */
  184. create() {
  185. this.$refs.addEditDialog.open('add');
  186. },
  187. /**
  188. * 编辑
  189. */
  190. edit(data) {
  191. this.$refs.addEditDialog.open('edit', data);
  192. },
  193. /**
  194. * table选择列被改变时
  195. * @param {Array} data 选中的列
  196. */
  197. selectionChange(data) {
  198. this.selection = data;
  199. this.ids = data.map((item) => {
  200. return item.id;
  201. });
  202. },
  203. showDetailsDialog(data) {
  204. this.$refs.detailsDialog.open(data);
  205. },
  206. // 进入审批页面则执行该函数
  207. changeShow() {
  208. this.show = 0;
  209. },
  210. queryListData() {
  211. this.listLoading = true;
  212. let obj = {
  213. examineFlag: this.show === 0 ? 0 : null,
  214. ...this.page,
  215. ...this.searchForm,
  216. platform: 'web',
  217. sort: {
  218. order: 'desc',
  219. orderBy: 'create_time',
  220. },
  221. };
  222. queryPage(obj)
  223. .then((res) => {
  224. if (res.statusCode == '10') {
  225. this.$router.replace('/login');
  226. }
  227. this.tableData = res.data.records;
  228. this.tableData.forEach((item) => {
  229. if (item.imgs) {
  230. item.imgs = item.imgs.split(',');
  231. }
  232. });
  233. this.total = res.data.total;
  234. this.listLoading = false;
  235. })
  236. .catch(() => {
  237. this.listLoading = false;
  238. });
  239. },
  240. // 页码变化时
  241. handlePagination(val) {
  242. this.page = val;
  243. this.queryListData();
  244. },
  245. /**
  246. * 删除功能
  247. * @param {String} type 授权操作类型:'batch'批量授权 'single'单个授权
  248. * @param {Number} id 当前需要删除的id或集合
  249. */
  250. deleteData(id, type = 'single') {
  251. let obj = {};
  252. if (type === 'batch') {
  253. if (this.ids.length === 0) return this.$message.warning('请至少选中一项 !');
  254. // console.log(this.ids, "ids");
  255. obj = {
  256. ids: this.ids,
  257. };
  258. this.delete(obj);
  259. } else {
  260. obj = {
  261. ids: [id],
  262. };
  263. this.delete(obj);
  264. }
  265. },
  266. delete(obj) {
  267. this.$confirm('确定要删除该数据吗?', '提示', {
  268. confirmButtonText: '确定',
  269. cancelButtonText: '取消',
  270. type: 'warning',
  271. closeOnClickModal: false,
  272. })
  273. .then(() => {
  274. removeData(obj)
  275. .then(() => {
  276. this.$message.success('删除成功');
  277. this.queryListData();
  278. })
  279. .catch(() => {});
  280. })
  281. .catch(() => {});
  282. },
  283. // 启用状态改变时
  284. switchChange(val, id) {
  285. let obj = {
  286. statuz: val,
  287. id,
  288. };
  289. this.changeData(obj);
  290. },
  291. //首页展示
  292. switchShow(val, id) {
  293. let obj = {
  294. hotFlag: val,
  295. id,
  296. };
  297. this.changeData(obj);
  298. },
  299. // 编辑
  300. changeData(data) {
  301. editData(data)
  302. .then(() => {
  303. this.$message.success('修改成功');
  304. this.queryListData();
  305. })
  306. .catch((err) => err);
  307. },
  308. // 置顶
  309. // toTop(id, type) {
  310. // if (type !== 1) {
  311. // toUp(id)
  312. // .then(() => {
  313. // this.$message.success('操作成功');
  314. // this.queryListData();
  315. // })
  316. // .catch(err => err);
  317. // } else {
  318. // let obj = {
  319. // id,
  320. // hotFlag: 0,
  321. // };
  322. // editData(obj).then(() => {
  323. // this.$message.success('操作成功');
  324. // this.queryListData();
  325. // });
  326. // }
  327. // },
  328. // 批量开启
  329. batchPutaway() {
  330. const ids = this.selection.filter((item) => {
  331. return item.examineFlag === 1;
  332. });
  333. const arr = ids.map((item) => {
  334. return item.id;
  335. });
  336. if (arr.length === 0) {
  337. this.$message.warning('请至少选中一项审核通过的!');
  338. return false;
  339. }
  340. useBath({ ids: arr })
  341. .then(() => {
  342. this.$message.success('操作成功');
  343. this.queryListData();
  344. })
  345. .catch(() => {});
  346. },
  347. // 批量关闭
  348. batchUnshelve() {
  349. const ids = this.selection.filter((item) => {
  350. return item.examineFlag === 1;
  351. });
  352. const arr = ids.map((item) => {
  353. return item.id;
  354. });
  355. if (arr.length === 0) {
  356. this.$message.warning('请至少选中一项审核通过的!');
  357. return false;
  358. }
  359. noUseBath({ ids: arr })
  360. .then(() => {
  361. this.$message.success('操作成功');
  362. this.queryListData();
  363. })
  364. .catch((err) => err);
  365. },
  366. // 查询
  367. query() {
  368. for (let k in this.searchForm) {
  369. if (this.searchForm[k] === '') {
  370. delete this.searchForm[k];
  371. }
  372. }
  373. this.page.pageNum = 1;
  374. this.queryListData();
  375. },
  376. // 重置
  377. reset() {
  378. this.searchForm = {};
  379. this.$refs.brand.reset();
  380. this.page.pageNum = 1;
  381. this.queryListData();
  382. },
  383. // 审核通过 (仅在审批页面使用)
  384. pass(id) {
  385. this.$confirm('是否通过审批?', '提示', {
  386. confirmButtonText: '确定',
  387. cancelButtonText: '取消',
  388. type: 'warning',
  389. })
  390. .then(() => {
  391. let obj = {
  392. id,
  393. examineFlag: 1,
  394. };
  395. this.approval(obj);
  396. })
  397. .catch(() => {
  398. this.$message({
  399. type: 'info',
  400. message: '已取消',
  401. });
  402. });
  403. },
  404. // 驳回弹框
  405. rejectShow(id) {
  406. this.$refs.regectDialog.open(id);
  407. },
  408. // 驳回 (审批页面调用)
  409. isReject(data) {
  410. let obj = {
  411. id: data.id,
  412. notExamineReason: data.checkComment,
  413. examineFlag: 2,
  414. };
  415. this.approval(obj);
  416. },
  417. // 审批
  418. approval(data) {
  419. examine(data).then((res) => {
  420. if (res.statusCode === '1') {
  421. this.$message.success('操作成功');
  422. } else {
  423. this.$message.success(res.message);
  424. }
  425. this.queryListData();
  426. });
  427. },
  428. brandChange(data) {
  429. if (data.id) {
  430. this.searchForm.brandId = data.id;
  431. } else {
  432. this.searchForm.brandId = null;
  433. }
  434. },
  435. imgOpen(imgs) {
  436. window.open(imgs);
  437. },
  438. },
  439. };
  440. </script>
  441. <style lang="stylus" scoped>
  442. .my-open-img{
  443. ::v-deep .el-image{
  444. img{
  445. pointer-events: auto;
  446. }
  447. .el-icon-circle-close {
  448. font-size: 50px;
  449. color: #fff;
  450. }
  451. }
  452. }
  453. </style>