const fs = require("fs") const path = require("path") const feeding = fs.readFileSync( path.join(__dirname, "../src/views/breedingStandards/feeding/index.vue"), "utf8" ) function patch(s, pairs) { let o = s for (const [a, b] of pairs) { o = o.split(a).join(b) } return o } const base = path.join(__dirname, "../src/views/breedingStandards") fs.writeFileSync( path.join(base, "equipmentOperation/index.vue"), patch(feeding, [ ["FeedingManageStandard", "EquipmentOperationStandard"], ['stdNs: "feed"', 'stdNs: "eqp"'], ["feeding:standard", "equipment:workStandard"], ["listFeedingStandard", "listEquipmentWorkStandard"], ["getFeedingStandard", "getEquipmentWorkStandard"], ["addFeedingStandard", "addEquipmentWorkStandard"], ["updateFeedingStandard", "updateEquipmentWorkStandard"], ["delFeedingStandard", "delEquipmentWorkStandard"], ["syncKbFeedingStandard", "syncKbEquipmentWorkStandard"], ["removeKbFeedingStandard", "removeKbEquipmentWorkStandard"], ["publishFeedingStandard", "publishEquipmentWorkStandard"], ["offlineFeedingStandard", "offlineEquipmentWorkStandard"], ["@/api/breedingStandards/feedingManage", "@/api/breedingStandards/equipmentWorkStandard"], ["breedingStd.feed.confirmDelete", "breedingStd.eqp.confirmDelete"], [ 'return [1, 2].map((value) => ({ label: this.stdT("type" + value), value }))', 'return [1, 2, 3, 4].map((value) => ({ label: this.stdT("type" + value), value }))' ] ]) ) let growth = patch(feeding, [ ["FeedingManageStandard", "GrowthOutboundStandard"], ['stdNs: "feed"', 'stdNs: "growth"'], ["feeding:standard", "growthSlaughter:standard"], ["listFeedingStandard", "listGrowthSlaughterStandard"], ["getFeedingStandard", "getGrowthSlaughterStandard"], ["addFeedingStandard", "addGrowthSlaughterStandard"], ["updateFeedingStandard", "updateGrowthSlaughterStandard"], ["delFeedingStandard", "delGrowthSlaughterStandard"], ["syncKbFeedingStandard", "syncKbGrowthSlaughterStandard"], ["removeKbFeedingStandard", "removeKbGrowthSlaughterStandard"], ["publishFeedingStandard", "publishGrowthSlaughterStandard"], ["offlineFeedingStandard", "offlineGrowthSlaughterStandard"], ["@/api/breedingStandards/feedingManage", "@/api/breedingStandards/growthSlaughter"], ["breedingStd.feed.confirmDelete", "breedingStd.growth.confirmDelete"], ['min: 3, max: 20, message: this.$t("breedingStd.common.ruleLen3120"', 'min: 1, max: 20, message: this.$t("breedingStd.common.ruleLen120"'] ]) fs.writeFileSync(path.join(base, "growthOutbound/index.vue"), growth) let ep = patch(feeding, [ ["FeedingManageStandard", "EpidemicTreatmentStandard"], ['stdNs: "feed"', 'stdNs: "ep"'], ["feeding:standard", "epidemicTreatment:standard"], ["listFeedingStandard", "listEpidemicTreatmentStandard"], ["getFeedingStandard", "getEpidemicTreatmentStandard"], ["addFeedingStandard", "addEpidemicTreatmentStandard"], ["updateFeedingStandard", "updateEpidemicTreatmentStandard"], ["delFeedingStandard", "delEpidemicTreatmentStandard"], ["syncKbFeedingStandard", "syncKbEpidemicTreatmentStandard"], ["removeKbFeedingStandard", "removeKbEpidemicTreatmentStandard"], ["publishFeedingStandard", "publishEpidemicTreatmentStandard"], ["offlineFeedingStandard", "offlineEpidemicTreatmentStandard"], ["@/api/breedingStandards/feedingManage", "@/api/breedingStandards/epidemicTreatment"], ["breedingStd.feed.confirmDelete", "breedingStd.ep.confirmDelete"], [ 'return [1, 2].map((value) => ({ label: this.stdT("type" + value), value }))', 'return [1].map((value) => ({ label: this.stdT("type" + value), value }))' ], ['min: 3, max: 20, message: this.$t("breedingStd.common.ruleLen3120"', 'min: 1, max: 20, message: this.$t("breedingStd.common.ruleLen120"'] ]) fs.writeFileSync(path.join(base, "diseaseTreatment/epidemicTreatment/index.vue"), ep) console.log("generated equipment, growth, epidemic from feeding template")