index.vue 21 KB

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