| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- const fs = require('fs');
- const path = 'd:/front-end/hdApp/src/admin/home/workbench.vue';
- const lines = fs.readFileSync(path, 'utf8').split(/\r?\n/);
- let tpl = lines.slice(55, 234).join('\n');
- tpl = tpl.replace('<view class="order-page">', '<view class="purchase-ghs-panel">');
- const popups = lines.slice(240, 278).join('\n');
- const initBlock = lines.slice(470, 482).join('\n');
- const ghsMethods = lines.slice(492, 711).join('\n');
- let fixedMethods = (initBlock + '\n' + ghsMethods).replace(
- ' init() {\n this.getGHSList()',
- ' init() {\n return this.getGHSList()'
- );
- let styles = lines.slice(1377, 1493).join('\n') + '\n' + lines.slice(1494, 2009).join('\n');
- styles = styles.replace(/\.order-page/g, '.purchase-ghs-panel');
- const script = `<script>
- import { mapGetters } from "vuex";
- import { consoleIndex } from "@/api/workbench";
- import { ghsList } from "@/api/purchase";
- import { changeDelStatus, hasMoreGhs, searchNearbyGhs } from "@/api/ghs";
- import { currentShop } from "@/api/shop";
- import { hasNotice } from "@/api/admin";
- import permision from "@/utils/wa-permission_1.1/permission.js";
- import { iconSrc } from "@/utils/iconSrc";
- export default {
- name: "PurchaseGhsPanel",
- props: {
- statusBarHeight: { type: Number, default: 0 }
- },
- data() {
- return {
- constant: this.$constant,
- ad: [],
- isMini: 0,
- data: {
- admin: {},
- asset: {},
- notice: {},
- todayData: { income: 0.00, order: 0, custom: 0, expend: 0.00, visit: 0 },
- warning: ''
- },
- supplierList: [],
- currentGhs: {},
- displayGhsList: [],
- shopInfo: [],
- supplierSearchTime: 0,
- hasRequestApi: 0
- };
- },
- computed: {
- ...mapGetters({ loginInfo: "getLoginInfo" }),
- workbenchTitle() {
- if (this.shopInfo && this.shopInfo.shopName == '首店') {
- return this.shopInfo.merchantName || '进货'
- }
- const merchantName = (this.shopInfo && this.shopInfo.merchantName) ? this.shopInfo.merchantName : ''
- const shopName = (this.shopInfo && this.shopInfo.shopName) ? this.shopInfo.shopName : ''
- const title = merchantName + (shopName ? (' · ' + shopName) : '')
- return title || '进货'
- },
- isWithinTwoDays() {
- if (!this.supplierSearchTime) return false;
- const twoDays = 2 * 24 * 60 * 60 * 1000;
- return (Date.now() - this.supplierSearchTime) < twoDays;
- }
- },
- beforeDestroy() {
- this.handlePageUnload();
- },
- methods: {
- iconSrc,
- handlePageLoad() {},
- handlePageUnload() {},
- handlePageShow() {
- this.supplierSearchTime = uni.getStorageSync('supplier_search_time') || 0;
- this.init();
- this.toRemindCustom();
- },
- handlePullDownRefresh() {
- return Promise.resolve(this.init()).then(() => {
- uni.stopPullDownRefresh();
- });
- },
- getShareMessage(res) {
- if (res && res.from === 'button' && res.target && res.target.dataset && res.target.dataset.ghs) {
- const ghsInfo = res.target.dataset.ghs;
- const hdShopAdminId = this.loginInfo && this.loginInfo.shopAdminId ? this.loginInfo.shopAdminId : 0;
- const ghsShopAdminId = ghsInfo.shopAdminId || 0;
- const shopId = ghsInfo.shopId || 0;
- const fromGhsId = ghsInfo.id || 0;
- const fromCg = 1;
- const path = \`/pagesPurchase/ghsProduct?hdShopAdminId=\${hdShopAdminId}&ghsShopAdminId=\${ghsShopAdminId}&shopId=\${shopId}&id=0&fromGhsId=\${fromGhsId}&fromCg=\${fromCg}\`;
- return {
- title: ghsInfo.name,
- desc: "",
- path: path,
- imageUrl: ghsInfo.avatar || ghsInfo.smallAvatar || ''
- };
- }
- return null;
- },
- ${fixedMethods}
- }
- };
- </script>`;
- const out = `<template>\n${tpl}\n${popups}\n</template>\n${script}\n<style lang="scss" scoped>\n${styles}\n</style>\n`;
- fs.writeFileSync('d:/front-end/hdApp/src/admin/home/components/purchase-ghs-panel.vue', out);
- console.log('written', out.length);
|