index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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">
  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="organName"
  79. label="分部"
  80. ></el-table-column>
  81. <el-table-column
  82. align="center"
  83. prop="cooperationOrganName"
  84. label="合作单位"
  85. >
  86. <template slot-scope="scope">
  87. <div>
  88. {{ scope.row.cooperationOrganName }}
  89. (<copy-text> {{ scope.row.cooperationOrganId }} </copy-text>)
  90. </div>
  91. </template>
  92. </el-table-column>
  93. <el-table-column
  94. align="center"
  95. prop="activeNum"
  96. label="调查人数"
  97. ></el-table-column>
  98. <el-table-column
  99. align="center"
  100. prop="replaceNum"
  101. label="置换人数"
  102. ></el-table-column>
  103. <el-table-column align="center" prop="replaceScale" label="置换率">
  104. <template slot-scope="scope">
  105. <div>{{ scope.row.replaceScale }}%</div>
  106. </template>
  107. </el-table-column>
  108. <el-table-column align="center" prop="openPay" label="是否开启缴费">
  109. <template slot-scope="scope">
  110. <div>{{ scope.row.openPay ? "是" : "否" }}</div>
  111. </template>
  112. </el-table-column>
  113. <el-table-column align="center" prop="studentId" label="操作">
  114. <template slot-scope="scope">
  115. <div>
  116. <!-- <el-button type="text" @click="lookDetail(scope.row)"
  117. >详情</el-button
  118. > -->
  119. <el-button
  120. type="text"
  121. @click="onCreateQRCode(scope.row, '调查链接')"
  122. >调查链接</el-button
  123. >
  124. <el-button
  125. type="text"
  126. @click="onCreateQRCode(scope.row, '统计链接')"
  127. >统计链接</el-button
  128. >
  129. <el-button
  130. type="text"
  131. @click="openPay(scope.row)"
  132. v-if="!scope.row.openPay&&permission('replacementInstrumentCooperation/openPay')"
  133. >开启缴费</el-button
  134. >
  135. </div>
  136. </template>
  137. </el-table-column>
  138. </el-table>
  139. <pagination
  140. sync
  141. :total.sync="rules.total"
  142. :page.sync="rules.page"
  143. :limit.sync="rules.limit"
  144. :page-sizes="rules.page_size"
  145. @pagination="getList"
  146. />
  147. </div>
  148. </div>
  149. <el-dialog
  150. title="生成链接"
  151. :visible.sync="makeUrlVisible"
  152. width="500px"
  153. v-if="makeUrlVisible"
  154. >
  155. <addUrl ref="addUrl" @close="close" @getList="getList" />
  156. <div slot="footer">
  157. <el-button @click="makeUrlVisible = false">取 消</el-button>
  158. <el-button type="primary" @click="addurl">生成链接</el-button>
  159. </div>
  160. </el-dialog>
  161. <el-dialog
  162. title="详情"
  163. :visible.sync="detailVisible"
  164. width="1000px"
  165. v-if="detailVisible"
  166. >
  167. <detail ref="detail" @close="close" />
  168. <div slot="footer">
  169. <el-button type="primary" @click="detailVisible = false"
  170. >确定</el-button
  171. >
  172. </div>
  173. </el-dialog>
  174. <qr-code v-model="qrcodeStatus"
  175. :title="qrcodeName"
  176. :codeUrl="codeUrl" />
  177. <!-- <el-dialog :title="qrcodeName" :visible.sync="qrcodeStatus" width="300px">
  178. <div class="left-code">
  179. <div id="qrcode" class="qrcode code" ref="qrCodeUrl"></div>
  180. <p class="code-url" v-if="codeUrl">
  181. <copy-text>
  182. {{ codeUrl }}
  183. </copy-text>
  184. </p>
  185. </div>
  186. </el-dialog> -->
  187. </div>
  188. </template>
  189. <script>
  190. import axios from "axios";
  191. import { getToken } from "@/utils/auth";
  192. import { permission } from "@/utils/directivePage";
  193. import { vaildStudentUrl, vaildTeachingUrl } from "@/utils/validate";
  194. import pagination from "@/components/Pagination/index";
  195. import addUrl from "./modals/addUrl";
  196. import detail from "./modals/detail";
  197. import load from "@/utils/loading";
  198. import { getReplacementList, openPayReplacement } from "./api";
  199. import QrCode from "@/components/QrCode/index";
  200. export default {
  201. components: { pagination, addUrl, detail, QrCode, },
  202. data() {
  203. return {
  204. searchForm: {
  205. search: null,
  206. organId: "",
  207. openPay: "",
  208. },
  209. tableList: [],
  210. rules: {
  211. // 分页规则
  212. limit: 10, // 限制显示条数
  213. page: 1, // 当前页
  214. total: 0, // 总条数
  215. page_size: [10, 20, 40, 50], // 选择限制显示条数
  216. },
  217. makeUrlVisible: false,
  218. detailVisible: false,
  219. codeUrl: "",
  220. qrcodes: true,
  221. qrcodeStatus: false,
  222. qrcodeName: "调查链接",
  223. };
  224. },
  225. //生命周期 - 创建完成(可以访问当前this实例)
  226. created() {},
  227. //生命周期 - 挂载完成(可以访问DOM元素)
  228. mounted() {
  229. // 获取分部
  230. this.init();
  231. },
  232. methods: {
  233. permission(str, parent) {
  234. return permission(str, parent);
  235. },
  236. init() {
  237. this.$store.dispatch("setBranchs");
  238. this.getList();
  239. },
  240. async getList() {
  241. try {
  242. const res = await getReplacementList({
  243. ...this.searchForm,
  244. page: this.rules.page,
  245. rows: this.rules.limit,
  246. });
  247. this.rules.total = res.data.total;
  248. this.tableList = res.data.rows;
  249. } catch (e) {
  250. console.log(e);
  251. }
  252. },
  253. search() {
  254. this.rules.page = 1;
  255. this.getList();
  256. },
  257. onReSet() {
  258. this.$refs.searchForm.resetFields()
  259. this.search()
  260. },
  261. makeUrl() {
  262. this.makeUrlVisible = true;
  263. },
  264. addurl() {
  265. this.$refs.addUrl.submit();
  266. },
  267. close() {
  268. this.makeUrlVisible = false;
  269. this.detailVisible = false;
  270. },
  271. onExport() {},
  272. lookDetail(row) {
  273. this.detailVisible = true;
  274. },
  275. onCreateQRCode(row, name) {
  276. // 生成链接
  277. this.qrcodeName = name;
  278. this.qrcodeStatus = true;
  279. let id = this.$route.query.id;
  280. if (this.qrcodes) {
  281. this.qrcodes = false;
  282. // setTimeout(() => {
  283. // document.getElementById("qrcode").innerHTML = "";
  284. // this.qrcode = new QRCode("qrcode", {
  285. // width: 260,
  286. // height: 260,
  287. // colorDark: "#000000",
  288. // colorLight: "#ffffff",
  289. // correctLevel: QRCode.CorrectLevel.H,
  290. // });
  291. let str;
  292. if (name == "调查链接") {
  293. let returnUrl = vaildStudentUrl()+`/#/questionnaire?o=${row.organId}&c=${row.cooperationOrganId}`;
  294. // console.log(returnUrl)
  295. let tempUrl = vaildStudentUrl()+`/#/transfer?returnUrl=${encodeURIComponent(returnUrl)}`
  296. str = tempUrl
  297. } else if (name == "统计链接") {
  298. str = vaildTeachingUrl()+`/#/questionStatistics?o=${row.organId}&c=${row.cooperationOrganId}`;
  299. }
  300. // vaildTeachingUrl
  301. // this.qrcode.makeCode(
  302. // str +
  303. // `/#/questionnaireInfo?o=${row.organId}&c=${row.cooperationOrganId}`
  304. // );
  305. this.codeUrl =str;
  306. this.qrcodes = true;
  307. // }, 100);
  308. }
  309. },
  310. openPay(row) {
  311. this.$confirm("确定开启缴费?", "提示", {
  312. confirmButtonText: "确定",
  313. cancelButtonText: "取消",
  314. type: "warning",
  315. })
  316. .then(async () => {
  317. try {
  318. const res = await openPayReplacement({ id: row.id });
  319. this.$message.success("开启缴费成功");
  320. this.getList();
  321. } catch (e) {
  322. console.log(e);
  323. }
  324. })
  325. .catch(() => {});
  326. },
  327. },
  328. };
  329. </script>
  330. <style lang='scss' scoped>
  331. .btnList {
  332. display: flex;
  333. flex-direction: row;
  334. justify-content: flex-start;
  335. }
  336. .code-url {
  337. margin-top: 10px;
  338. }
  339. </style>