index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <!-- -->
  2. <template>
  3. <div class="m-container">
  4. <h2>
  5. <div class="squrt"></div>
  6. 乐器置换
  7. </h2>
  8. <div class="m-core">
  9. <div class="btnList">
  10. <!-- v-permission="'export/practiceGroup'" -->
  11. <div
  12. class="newBand"
  13. @click="makeUrl('create')"
  14. style="max-width: 150px; margin-right: 10px"
  15. v-if="permission('replacementInstrumentCooperation/add')"
  16. >
  17. 生成链接
  18. </div>
  19. <div class="newBand" @click="onExport" style="max-width: 150px" v-if="permission('replacementInstrumentActivity/export')">
  20. 导出
  21. </div>
  22. </div>
  23. <save-form
  24. :inline="true"
  25. ref="searchForm"
  26. :model="searchForm"
  27. @submit="search"
  28. @reset="onReSet"
  29. >
  30. <el-form-item prop="search">
  31. <el-input
  32. v-model.trim="searchForm.search"
  33. clearable
  34. @keyup.enter.native="search"
  35. placeholder="学校名称或编号"
  36. ></el-input>
  37. </el-form-item>
  38. <el-form-item prop="organId">
  39. <el-select
  40. v-model.trim="searchForm.organId"
  41. filterable
  42. clearable
  43. placeholder="请选择分部"
  44. >
  45. <el-option
  46. v-for="(item, index) in selects.branchs"
  47. :key="index"
  48. :label="item.name"
  49. :value="item.id"
  50. ></el-option>
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item prop="openPay">
  54. <el-select
  55. class="multiple"
  56. v-model.trim="searchForm.openPay"
  57. filterable
  58. clearable
  59. placeholder="是否开启缴费"
  60. >
  61. <el-option label="是" value="YES"></el-option>
  62. <el-option label="否" value="NO"></el-option>
  63. </el-select>
  64. </el-form-item>
  65. <el-form-item>
  66. <el-button native-type="submit" type="primary">搜索</el-button>
  67. <el-button native-type="reset" type="danger">重置</el-button>
  68. </el-form-item>
  69. </save-form>
  70. <div class="tableWrap">
  71. <el-table
  72. style="width: 100%"
  73. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  74. :data="tableList"
  75. >
  76. <el-table-column
  77. align="center"
  78. prop="id"
  79. label="编号"
  80. ></el-table-column>
  81. <el-table-column
  82. align="center"
  83. prop="title"
  84. label="活动主题"
  85. ></el-table-column>
  86. <el-table-column
  87. align="center"
  88. prop="organName"
  89. label="分部"
  90. ></el-table-column>
  91. <el-table-column
  92. align="center"
  93. prop="cooperationOrganName"
  94. label="合作单位"
  95. >
  96. <template slot-scope="scope">
  97. <div>
  98. {{ scope.row.cooperationOrganName }}
  99. <!-- (<copy-text> {{ scope.row.cooperationOrganId }} </copy-text>) -->
  100. </div>
  101. </template>
  102. </el-table-column>
  103. <el-table-column align="center" label="问卷名称">
  104. <template slot-scope="scope">
  105. <span v-if="scope.row.topicTitle">{{ scope.row.topicTitle }}</span>
  106. <el-tag style="margin: 8px 20px; font-size: 14px;" type="danger" v-else>无问卷</el-tag>
  107. </template>
  108. </el-table-column>
  109. <!-- <el-table-column
  110. align="center"
  111. prop="showQuestion"
  112. label="是否参加问卷调查"
  113. >
  114. <template slot-scope="scope">
  115. {{ scope.row.showQuestion ? '是' : '否' }}
  116. </template>
  117. </el-table-column> -->
  118. <el-table-column
  119. align="center"
  120. prop="activeNum"
  121. label="调查人数"
  122. ></el-table-column>
  123. <el-table-column
  124. align="center"
  125. prop="replaceNum"
  126. label="置换人数"
  127. ></el-table-column>
  128. <el-table-column align="center" prop="replaceScale" label="置换率">
  129. <template slot-scope="scope">
  130. <div>{{ scope.row.replaceScale }}%</div>
  131. </template>
  132. </el-table-column>
  133. <el-table-column align="center" prop="replaceScale" label="缴费率">
  134. <template slot-scope="scope">
  135. <div>{{ scope.row.payScale }}%</div>
  136. </template>
  137. </el-table-column>
  138. <el-table-column align="center" prop="openPay" label="是否开启缴费">
  139. <template slot-scope="scope">
  140. <div>{{ scope.row.openPay ? "是" : "否" }}</div>
  141. </template>
  142. </el-table-column>
  143. <el-table-column align="center" width="250px" label="操作">
  144. <template slot-scope="scope">
  145. <div>
  146. <el-button type="text" @click="lookDetail(scope.row)" v-if="permission('replacementInstrumentActivity/queryPage')">问卷详情</el-button>
  147. <el-button type="text" @click="lookDetail(scope.row, 'answer')" v-if="permission('/reaplceMusicPlayer/answer')">问答详情</el-button>
  148. <el-button type="text" @click="makeUrl('update', scope.row)" v-if="permission('replacementInstrumentCooperation/update')">修改主题</el-button>
  149. <el-button
  150. type="text"
  151. @click="openPay(scope.row)"
  152. v-if="
  153. !scope.row.openPay &&
  154. permission('replacementInstrumentCooperation/openPay')
  155. "
  156. >开启缴费</el-button>
  157. <el-dropdown>
  158. <span class="el-dropdown-link" style="color: #14928A">
  159. 更多操作<i class="el-icon-arrow-down el-icon--right"></i>
  160. </span>
  161. <el-dropdown-menu slot="dropdown" style="margin-left: 10px;">
  162. <el-dropdown-item>
  163. <el-button type="text" @click="onCreateQRCode(scope.row, '调查链接')" >调查链接</el-button>
  164. </el-dropdown-item>
  165. <el-dropdown-item>
  166. <el-button type="text" @click="onCreateQRCode(scope.row, '统计链接')">统计链接</el-button>
  167. </el-dropdown-item>
  168. <el-dropdown-item>
  169. <el-button type="text" @click="onCreateQRCode(scope.row, '缴费链接')">缴费链接</el-button>
  170. </el-dropdown-item>
  171. </el-dropdown-menu>
  172. </el-dropdown>
  173. </div>
  174. </template>
  175. </el-table-column>
  176. </el-table>
  177. <pagination
  178. sync
  179. :total.sync="rules.total"
  180. :page.sync="rules.page"
  181. :limit.sync="rules.limit"
  182. :page-sizes="rules.page_size"
  183. @pagination="getList"
  184. />
  185. </div>
  186. </div>
  187. <el-dialog
  188. :title="makeType == 'create' ? '生成链接' : '修改链接'"
  189. :visible.sync="makeUrlVisible"
  190. width="500px"
  191. v-if="makeUrlVisible"
  192. >
  193. <addUrl ref="addUrl" @close="close" :makeType="makeType" :makeDetail="makeDetail" @getList="getList" />
  194. <div slot="footer">
  195. <el-button @click="makeUrlVisible = false">取 消</el-button>
  196. <el-button type="primary" @click="addurl">{{ makeType == 'create' ? '生成链接' : '修改链接' }}</el-button>
  197. </div>
  198. </el-dialog>
  199. <el-dialog
  200. title="详情"
  201. :visible.sync="detailVisible"
  202. width="1200px"
  203. @close="getClose"
  204. v-if="detailVisible"
  205. >
  206. <detail ref="detail" @close="close" :detail="activeRow" />
  207. <div slot="footer">
  208. <el-button type="primary" @click="getClose"
  209. >确定</el-button
  210. >
  211. </div>
  212. </el-dialog>
  213. <qr-code v-model="qrcodeStatus" :title="qrcodeName" :codeUrl="codeUrl" />
  214. <!-- <el-dialog :title="qrcodeName" :visible.sync="qrcodeStatus" width="300px">
  215. <div class="left-code">
  216. <div id="qrcode" class="qrcode code" ref="qrCodeUrl"></div>
  217. <p class="code-url" v-if="codeUrl">
  218. <copy-text>
  219. {{ codeUrl }}
  220. </copy-text>
  221. </p>
  222. </div>
  223. </el-dialog> -->
  224. </div>
  225. </template>
  226. <script>
  227. import { permission } from "@/utils/directivePage";
  228. import { vaildStudentUrl, vaildTeachingUrl } from "@/utils/validate";
  229. import pagination from "@/components/Pagination/index";
  230. import addUrl from "./modals/addUrl";
  231. import detail from "./modals/detail";
  232. import { getReplacementList, openPayReplacement, updateReplacement } from "./api";
  233. import { Export } from '@/utils/downLoadFile'
  234. import cleanDeep from 'clean-deep'
  235. import qs from 'qs';
  236. import QrCode from "@/components/QrCode/index";
  237. import { encode } from 'js-base64';
  238. export default {
  239. components: { pagination, addUrl, detail, QrCode },
  240. data() {
  241. return {
  242. searchForm: {
  243. search: null,
  244. organId: "",
  245. openPay: "",
  246. },
  247. tableList: [],
  248. rules: {
  249. // 分页规则
  250. limit: 10, // 限制显示条数
  251. page: 1, // 当前页
  252. total: 0, // 总条数
  253. page_size: [10, 20, 40, 50], // 选择限制显示条数
  254. },
  255. makeUrlVisible: false,
  256. makeType: 'create',
  257. detailVisible: false,
  258. makeDetail: null,
  259. codeUrl: "",
  260. qrcodes: true,
  261. qrcodeStatus: false,
  262. qrcodeName: "调查链接",
  263. activeRow: null,
  264. };
  265. },
  266. //生命周期 - 创建完成(可以访问当前this实例)
  267. created() {},
  268. //生命周期 - 挂载完成(可以访问DOM元素)
  269. mounted() {
  270. // 获取分部
  271. this.init();
  272. },
  273. methods: {
  274. permission(str, parent) {
  275. return permission(str, parent);
  276. },
  277. init() {
  278. this.$store.dispatch("setBranchs");
  279. this.getList();
  280. },
  281. async getList() {
  282. try {
  283. const res = await getReplacementList({
  284. ...this.searchForm,
  285. page: this.rules.page,
  286. rows: this.rules.limit,
  287. });
  288. this.rules.total = res.data.total;
  289. this.tableList = res.data.rows;
  290. } catch (e) {
  291. console.log(e);
  292. }
  293. },
  294. search() {
  295. this.rules.page = 1;
  296. this.getList();
  297. },
  298. onReSet() {
  299. this.$refs.searchForm.resetFields();
  300. this.search();
  301. },
  302. makeUrl(type, row) {
  303. this.makeUrlVisible = true;
  304. this.makeType = type
  305. if(type == 'update') {
  306. this.makeDetail = row
  307. }
  308. },
  309. addurl() {
  310. this.$refs.addUrl.submit();
  311. },
  312. close() {
  313. this.makeUrlVisible = false;
  314. this.detailVisible = false;
  315. },
  316. getClose() {
  317. this.detailVisible = false
  318. this.getList()
  319. },
  320. async onExport() {
  321. const { search, ...rest } = this.searchForm;
  322. let obj = {
  323. ...rest,
  324. // activeType: 'REPLACEMENT',
  325. page: this.rules.page,
  326. rows: this.rules.limit,
  327. cooperationOrganIdOrName:search
  328. };
  329. await Export(
  330. this,
  331. {
  332. url: "/api-web/replacementInstrumentActivity/export",
  333. fileName: "乐器置换列表.xls",
  334. method: "post",
  335. params: qs.stringify(cleanDeep(obj)),
  336. },
  337. "您确定导出乐器置换列表"
  338. );
  339. },
  340. lookDetail(row, type) {
  341. if(type == 'answer') {
  342. this.$router.push({
  343. path: '/reaplceMusicPlayer/answer',
  344. query: {
  345. id: row.id,
  346. topicId: row.topicId
  347. }
  348. })
  349. } else {
  350. this.activeRow = row;
  351. this.detailVisible = true;
  352. }
  353. },
  354. onCreateQRCode(row, name) {
  355. // 生成链接
  356. this.qrcodeName = name;
  357. this.qrcodeStatus = true;
  358. let id = this.$route.query.id;
  359. if (this.qrcodes) {
  360. this.qrcodes = false;
  361. // setTimeout(() => {
  362. // document.getElementById("qrcode").innerHTML = "";
  363. // this.qrcode = new QRCode("qrcode", {
  364. // width: 260,
  365. // height: 260,
  366. // colorDark: "#000000",
  367. // colorLight: "#ffffff",
  368. // correctLevel: QRCode.CorrectLevel.H,
  369. // });
  370. let str;
  371. if (name == "调查链接") {
  372. let returnUrl = vaildStudentUrl() + `/#/questionnaire?` + encodeURIComponent(encode(`id=${row.id}`));
  373. // console.log(returnUrl)
  374. // let tempUrl =
  375. // vaildStudentUrl() +
  376. // `/#/transfer?returnUrl=${encodeURIComponent(returnUrl)}`;
  377. str = returnUrl;
  378. } else if (name == "统计链接") {
  379. str =
  380. vaildTeachingUrl() +
  381. `/#/questionStatistics?o=${row.organId}&c=${row.cooperationOrganId}&id=${row.id}`;
  382. } else if(name == '缴费链接') {
  383. str = vaildStudentUrl() + `/#/questionGoodsSale?` + encodeURIComponent(encode(`rid=${row.id}`));
  384. }
  385. // vaildTeachingUrl
  386. // this.qrcode.makeCode(
  387. // str +
  388. // `/#/questionnaireInfo?o=${row.organId}&c=${row.cooperationOrganId}`
  389. // );
  390. this.codeUrl = str;
  391. this.qrcodes = true;
  392. // }, 100);
  393. }
  394. },
  395. openPay(row) {
  396. this.$confirm("确定开启缴费?", "提示", {
  397. confirmButtonText: "确定",
  398. cancelButtonText: "取消",
  399. type: "warning",
  400. })
  401. .then(async () => {
  402. try {
  403. const res = await openPayReplacement({ id: row.id });
  404. this.$message.success("开启缴费成功");
  405. this.getList();
  406. } catch (e) {
  407. console.log(e);
  408. }
  409. })
  410. .catch(() => {});
  411. },
  412. },
  413. };
  414. </script>
  415. <style lang='scss' scoped>
  416. .btnList {
  417. display: flex;
  418. flex-direction: row;
  419. justify-content: flex-start;
  420. }
  421. .code-url {
  422. margin-top: 10px;
  423. }
  424. </style>