guhongwei 1 年之前
父節點
當前提交
961c135a58
共有 6 個文件被更改,包括 156 次插入0 次删除
  1. 2 0
      package.json
  2. 20 0
      src/layout/site.js
  3. 42 0
      src/store/app/moneylog.js
  4. 42 0
      src/store/app/vipsetting.js
  5. 43 0
      src/util/htmlToPdf.js
  6. 7 0
      src/util/simfang-normal.js

+ 2 - 0
package.json

@@ -11,8 +11,10 @@
     "animate.css": "^4.1.1",
     "axios": "^1.2.2",
     "core-js": "^3.6.5",
+    "dom-to-image": "^2.6.0",
     "element-ui": "^2.15.12",
     "jsonwebtoken": "^9.0.0",
+    "jspdf": "^2.5.1",
     "lodash": "^4.17.21",
     "moment": "^2.29.4",
     "naf-core": "^0.1.2",

+ 20 - 0
src/layout/site.js

@@ -178,6 +178,26 @@ export const menus = [
         name: '用户管理',
         path: '/app/users',
       },
+      {
+        _id: 'me3us_2_8',
+        icon: 'el-icon-user',
+        name: 'vip管理',
+        type: '1',
+        children: [
+          {
+            _id: 'me3us_2_8_1',
+            icon: 'el-icon-user',
+            name: 'vip设置',
+            path: '/app/vip/setting',
+          },
+          {
+            _id: 'me3us_2_8_2',
+            icon: 'el-icon-user',
+            name: '消费记录',
+            path: '/app/vip/money',
+          },
+        ],
+      },
     ],
   },
   {

+ 42 - 0
src/store/app/moneylog.js

@@ -0,0 +1,42 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  test: `/projectadmin/api/moneylog`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.test}`, {
+      skip,
+      limit,
+      ...info,
+    });
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.test}/${payload}`);
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.test}`, payload);
+    return res;
+  },
+  async update({ commit }, { _id, ...info } = {}) {
+    const res = await this.$axios.$post(`${api.test}/${_id}`, { ...info });
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.test}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 42 - 0
src/store/app/vipsetting.js

@@ -0,0 +1,42 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  test: `/projectadmin/api/vipsetting`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.test}`, {
+      skip,
+      limit,
+      ...info,
+    });
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.test}/${payload}`);
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.test}`, payload);
+    return res;
+  },
+  async update({ commit }, { _id, ...info } = {}) {
+    const res = await this.$axios.$post(`${api.test}/${_id}`, { ...info });
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.test}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 43 - 0
src/util/htmlToPdf.js

@@ -0,0 +1,43 @@
+import domtoimage from 'dom-to-image';
+import JsPDF from 'jspdf';
+import './simfang-normal';
+/**
+ * @param  ele
+ * @param  pdfName
+ * */
+function createPDF(ele, pdfName, other) {
+  // 生成base64图片码
+  domtoimage
+    .toPng(ele, {})
+    .then(function (dataUrl) {
+      console.log('生成成功');
+      getPDF(ele, dataUrl, pdfName, other);
+    })
+    .catch(function (error) {
+      console.error('生成失败', error);
+    });
+}
+function getPDF(ele, url, name, other) {
+  // a4纸大小
+  var imgWidth = 595;
+  var imgHeight = 842;
+  var pdf = new JsPDF('', 'pt', 'a4');
+  // 添加字体
+  pdf.setFont('simfang');
+  // 水印
+  if (other && other.is_water == true) {
+    const pageHeight = pdf.getPageHeight();
+    pdf.saveGraphicsState();
+    pdf.setGState(pdf.GState({ opacity: 0.5 }));
+    pdf.setFontSize(18);
+    pdf.text(other.water, 100, pageHeight / 2, 42);
+    pdf.text(other.water, 110, pageHeight / 1.5, 42);
+    pdf.restoreGraphicsState();
+  }
+  pdf.addImage(url, 'JPEG', 0, 0, imgWidth, imgHeight);
+  pdf.save(name);
+}
+
+export default {
+  createPDF,
+};

文件差異過大導致無法顯示
+ 7 - 0
src/util/simfang-normal.js