index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  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"
  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="organName"
  84. label="分部"
  85. ></el-table-column>
  86. <el-table-column
  87. align="center"
  88. prop="cooperationOrganName"
  89. label="合作单位"
  90. >
  91. <template slot-scope="scope">
  92. <div>
  93. {{ scope.row.cooperationOrganName }}
  94. <!-- (<copy-text> {{ scope.row.cooperationOrganId }} </copy-text>) -->
  95. </div>
  96. </template>
  97. </el-table-column>
  98. <el-table-column align="center" label="问卷名称">
  99. <template slot-scope="scope">
  100. <span v-if="scope.row.topicTitle">{{ scope.row.topicTitle }}</span>
  101. <el-tag style="margin: 8px 20px; font-size: 14px;" type="danger" v-else>无问卷</el-tag>
  102. </template>
  103. </el-table-column>
  104. <!-- <el-table-column
  105. align="center"
  106. prop="showQuestion"
  107. label="是否参加问卷调查"
  108. >
  109. <template slot-scope="scope">
  110. {{ scope.row.showQuestion ? '是' : '否' }}
  111. </template>
  112. </el-table-column> -->
  113. <el-table-column
  114. align="center"
  115. prop="activeNum"
  116. label="调查人数"
  117. ></el-table-column>
  118. <el-table-column
  119. align="center"
  120. prop="replaceNum"
  121. label="置换人数"
  122. ></el-table-column>
  123. <el-table-column align="center" prop="replaceScale" label="置换率">
  124. <template slot-scope="scope">
  125. <div>{{ scope.row.replaceScale }}%</div>
  126. </template>
  127. </el-table-column>
  128. <el-table-column align="center" prop="replaceScale" label="缴费率">
  129. <template slot-scope="scope">
  130. <div>{{ scope.row.payScale }}%</div>
  131. </template>
  132. </el-table-column>
  133. <el-table-column align="center" prop="openPay" label="是否开启缴费">
  134. <template slot-scope="scope">
  135. <div>{{ scope.row.openPay ? "是" : "否" }}</div>
  136. </template>
  137. </el-table-column>
  138. <el-table-column align="center" width="250px" label="操作">
  139. <template slot-scope="scope">
  140. <div>
  141. <el-button type="text" @click="lookDetail(scope.row)" v-if="permission('replacementInstrumentActivity/queryPage')">问卷详情</el-button>
  142. <el-button type="text" @click="lookDetail(scope.row, 'answer')" v-if="permission('/reaplceMusicPlayer/answer')">问答详情</el-button>
  143. <el-button
  144. type="text"
  145. @click="onCreateQRCode(scope.row, '调查链接')"
  146. >调查链接</el-button
  147. >
  148. <el-button
  149. type="text"
  150. @click="onCreateQRCode(scope.row, '统计链接')"
  151. >统计链接</el-button
  152. >
  153. <el-button
  154. type="text"
  155. @click="openPay(scope.row)"
  156. v-if="
  157. !scope.row.openPay &&
  158. permission('replacementInstrumentCooperation/openPay')
  159. "
  160. >开启缴费</el-button
  161. >
  162. <el-button
  163. type="text"
  164. @click="onCreateQRCode(scope.row, '缴费链接')"
  165. v-if="scope.row.openPay">缴费链接</el-button>
  166. </div>
  167. </template>
  168. </el-table-column>
  169. </el-table>
  170. <pagination
  171. sync
  172. :total.sync="rules.total"
  173. :page.sync="rules.page"
  174. :limit.sync="rules.limit"
  175. :page-sizes="rules.page_size"
  176. @pagination="getList"
  177. />
  178. </div>
  179. </div>
  180. <el-dialog
  181. title="生成链接"
  182. :visible.sync="makeUrlVisible"
  183. width="500px"
  184. v-if="makeUrlVisible"
  185. >
  186. <addUrl ref="addUrl" @close="close" @getList="getList" />
  187. <div slot="footer">
  188. <el-button @click="makeUrlVisible = false">取 消</el-button>
  189. <el-button type="primary" @click="addurl">生成链接</el-button>
  190. </div>
  191. </el-dialog>
  192. <el-dialog
  193. title="详情"
  194. :visible.sync="detailVisible"
  195. width="1200px"
  196. @close="getClose"
  197. v-if="detailVisible"
  198. >
  199. <detail ref="detail" @close="close" :detail="activeRow" />
  200. <div slot="footer">
  201. <el-button type="primary" @click="getClose"
  202. >确定</el-button
  203. >
  204. </div>
  205. </el-dialog>
  206. <qr-code v-model="qrcodeStatus" :title="qrcodeName" :codeUrl="codeUrl" />
  207. <!-- <el-dialog :title="qrcodeName" :visible.sync="qrcodeStatus" width="300px">
  208. <div class="left-code">
  209. <div id="qrcode" class="qrcode code" ref="qrCodeUrl"></div>
  210. <p class="code-url" v-if="codeUrl">
  211. <copy-text>
  212. {{ codeUrl }}
  213. </copy-text>
  214. </p>
  215. </div>
  216. </el-dialog> -->
  217. </div>
  218. </template>
  219. <script>
  220. import { permission } from "@/utils/directivePage";
  221. import { vaildStudentUrl, vaildTeachingUrl } from "@/utils/validate";
  222. import pagination from "@/components/Pagination/index";
  223. import addUrl from "./modals/addUrl";
  224. import detail from "./modals/detail";
  225. import { getReplacementList, openPayReplacement } from "./api";
  226. import { Export } from '@/utils/downLoadFile'
  227. import cleanDeep from 'clean-deep'
  228. import qs from 'qs';
  229. import QrCode from "@/components/QrCode/index";
  230. import { encode } from 'js-base64';
  231. export default {
  232. components: { pagination, addUrl, detail, QrCode },
  233. data() {
  234. return {
  235. searchForm: {
  236. search: null,
  237. organId: "",
  238. openPay: "",
  239. },
  240. tableList: [],
  241. rules: {
  242. // 分页规则
  243. limit: 10, // 限制显示条数
  244. page: 1, // 当前页
  245. total: 0, // 总条数
  246. page_size: [10, 20, 40, 50], // 选择限制显示条数
  247. },
  248. makeUrlVisible: false,
  249. detailVisible: false,
  250. codeUrl: "",
  251. qrcodes: true,
  252. qrcodeStatus: false,
  253. qrcodeName: "调查链接",
  254. activeRow: null,
  255. };
  256. },
  257. //生命周期 - 创建完成(可以访问当前this实例)
  258. created() {},
  259. //生命周期 - 挂载完成(可以访问DOM元素)
  260. mounted() {
  261. // 获取分部
  262. this.init();
  263. },
  264. methods: {
  265. permission(str, parent) {
  266. return permission(str, parent);
  267. },
  268. init() {
  269. this.$store.dispatch("setBranchs");
  270. this.getList();
  271. },
  272. async getList() {
  273. try {
  274. const res = await getReplacementList({
  275. ...this.searchForm,
  276. page: this.rules.page,
  277. rows: this.rules.limit,
  278. });
  279. this.rules.total = res.data.total;
  280. this.tableList = res.data.rows;
  281. } catch (e) {
  282. console.log(e);
  283. }
  284. },
  285. search() {
  286. this.rules.page = 1;
  287. this.getList();
  288. },
  289. onReSet() {
  290. this.$refs.searchForm.resetFields();
  291. this.search();
  292. },
  293. makeUrl() {
  294. this.makeUrlVisible = true;
  295. },
  296. addurl() {
  297. this.$refs.addUrl.submit();
  298. },
  299. close() {
  300. this.makeUrlVisible = false;
  301. this.detailVisible = false;
  302. },
  303. getClose() {
  304. this.detailVisible = false
  305. this.getList()
  306. },
  307. async onExport() {
  308. const { search, ...rest } = this.searchForm;
  309. let obj = {
  310. ...rest,
  311. // activeType: 'REPLACEMENT',
  312. page: this.rules.page,
  313. rows: this.rules.limit,
  314. cooperationOrganIdOrName:search
  315. };
  316. await Export(
  317. this,
  318. {
  319. url: "/api-web/replacementInstrumentActivity/export",
  320. fileName: "乐器置换列表.xls",
  321. method: "post",
  322. params: qs.stringify(cleanDeep(obj)),
  323. },
  324. "您确定导出乐器置换列表"
  325. );
  326. },
  327. lookDetail(row, type) {
  328. if(type == 'answer') {
  329. this.$router.push({
  330. path: '/reaplceMusicPlayer/answer',
  331. query: {
  332. id: row.id,
  333. topicId: row.topicId
  334. }
  335. })
  336. } else {
  337. this.activeRow = row;
  338. this.detailVisible = true;
  339. }
  340. },
  341. onCreateQRCode(row, name) {
  342. // 生成链接
  343. this.qrcodeName = name;
  344. this.qrcodeStatus = true;
  345. let id = this.$route.query.id;
  346. if (this.qrcodes) {
  347. this.qrcodes = false;
  348. // setTimeout(() => {
  349. // document.getElementById("qrcode").innerHTML = "";
  350. // this.qrcode = new QRCode("qrcode", {
  351. // width: 260,
  352. // height: 260,
  353. // colorDark: "#000000",
  354. // colorLight: "#ffffff",
  355. // correctLevel: QRCode.CorrectLevel.H,
  356. // });
  357. let str;
  358. if (name == "调查链接") {
  359. let returnUrl = vaildStudentUrl() + `/#/questionnaire?` + encodeURIComponent(encode(`id=${row.id}`));
  360. // console.log(returnUrl)
  361. // let tempUrl =
  362. // vaildStudentUrl() +
  363. // `/#/transfer?returnUrl=${encodeURIComponent(returnUrl)}`;
  364. str = returnUrl;
  365. } else if (name == "统计链接") {
  366. str =
  367. vaildTeachingUrl() +
  368. `/#/questionStatistics?o=${row.organId}&c=${row.cooperationOrganId}&id=${row.id}`;
  369. } else if(name == '缴费链接') {
  370. str = vaildStudentUrl() + `/#/questionGoodsSale?` + encodeURIComponent(encode(`rid=${row.id}`));
  371. }
  372. // vaildTeachingUrl
  373. // this.qrcode.makeCode(
  374. // str +
  375. // `/#/questionnaireInfo?o=${row.organId}&c=${row.cooperationOrganId}`
  376. // );
  377. this.codeUrl = str;
  378. this.qrcodes = true;
  379. // }, 100);
  380. }
  381. },
  382. openPay(row) {
  383. this.$confirm("确定开启缴费?", "提示", {
  384. confirmButtonText: "确定",
  385. cancelButtonText: "取消",
  386. type: "warning",
  387. })
  388. .then(async () => {
  389. try {
  390. const res = await openPayReplacement({ id: row.id });
  391. this.$message.success("开启缴费成功");
  392. this.getList();
  393. } catch (e) {
  394. console.log(e);
  395. }
  396. })
  397. .catch(() => {});
  398. },
  399. },
  400. };
  401. </script>
  402. <style lang='scss' scoped>
  403. .btnList {
  404. display: flex;
  405. flex-direction: row;
  406. justify-content: flex-start;
  407. }
  408. .code-url {
  409. margin-top: 10px;
  410. }
  411. </style>