| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- # -*- coding: utf-8 -*-
- import os
- OUT = os.path.join(
- os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
- "ruoyi-ui", "src", "views", "production", "meatYieldAnalysis", "index.vue",
- )
- # Chinese via unicode escapes only
- LABELS = {
- "entrance_time": "\u5165\u573a\u65f6\u95f4",
- "to": "\u81f3",
- "start": "\u5f00\u59cb\u65e5\u671f",
- "end": "\u7ed3\u675f\u65e5\u671f",
- "search": "\u641c\u7d22",
- "reset": "\u91cd\u7f6e",
- "batch_no": "\u5165\u573a\u6279\u6b21",
- "batch_date": "\u6279\u6b21\u5165\u573a\u65e5\u671f",
- "gross": "\u6bdb\u91cd(kg)",
- "net": "\u51c0\u91cd(kg)",
- "avg_yield": "\u5e73\u5747\u51fa\u8089\u7387(%)",
- "action": "\u64cd\u4f5c",
- "detail": "\u8be6\u60c5",
- "individual": "\u4e2a\u4f53\u7f16\u53f7",
- "yield": "\u51fa\u8089\u7387(%)",
- "close": "\u5173 \u95ed",
- "detail_title": "\u6279\u6b21\u51fa\u8089\u7387\u8be6\u60c5 - ",
- }
- CONTENT = '''<template>
- <div class="app-container">
- <el-form ref="queryForm" :model="queryParams" :inline="true" size="small" v-show="showSearch" label-width="100px">
- <el-form-item label="{entrance_time}">
- <el-date-picker
- v-model="entranceTimeRange"
- type="daterange"
- range-separator="{to}"
- start-placeholder="{start}"
- end-placeholder="{end}"
- value-format="yyyy-MM-dd"
- style="width: 260px"
- />
- </el-form-item>
- <el-form-item>
- <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{search}</el-button>
- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{reset}</el-button>
- </el-form-item>
- </el-form>
- <el-row :gutter="10" class="mb8">
- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" />
- </el-row>
- <el-table border stripe v-loading="loading" :data="batchList">
- <el-table-column label="{batch_no}" prop="entranceBatchNo" align="center" min-width="100" />
- <el-table-column label="{batch_date}" prop="entranceTime" align="center" width="170" />
- <el-table-column label="{gross}" prop="grossWeight" align="center" width="110">
- <template slot-scope="scope">{{ formatWeight(scope.row.grossWeight) }}</template>
- </el-table-column>
- <el-table-column label="{net}" prop="netWeight" align="center" width="110">
- <template slot-scope="scope">{{ formatWeight(scope.row.netWeight) }}</template>
- </el-table-column>
- <el-table-column label="{avg_yield}" prop="avgMeatYield" align="center" width="130">
- <template slot-scope="scope">{{ formatPercent(scope.row.avgMeatYield) }}</template>
- </el-table-column>
- <el-table-column label="{action}" align="center" width="100" fixed="right">
- <template slot-scope="scope">
- <el-button type="text" size="mini" icon="el-icon-view" @click="handleDetail(scope.row)">{detail}</el-button>
- </template>
- </el-table-column>
- </el-table>
- <pagination
- v-show="total > 0"
- :total="total"
- :page.sync="queryParams.pageNum"
- :limit.sync="queryParams.pageSize"
- @pagination="getList"
- />
- <el-dialog
- :title="detailTitle"
- :visible.sync="detailOpen"
- width="900px"
- append-to-body
- @closed="detailList = []"
- >
- <el-table border stripe v-loading="detailLoading" :data="detailList" max-height="480">
- <el-table-column label="{individual}" prop="individualNo" align="center" min-width="120" />
- <el-table-column label="{gross}" prop="grossWeight" align="center" width="110">
- <template slot-scope="scope">{{ formatWeight(scope.row.grossWeight) }}</template>
- </el-table-column>
- <el-table-column label="{net}" prop="netWeight" align="center" width="110">
- <template slot-scope="scope">{{ formatWeight(scope.row.netWeight) }}</template>
- </el-table-column>
- <el-table-column label="{yield}" prop="meatYield" align="center" width="120">
- <template slot-scope="scope">{{ formatPercent(scope.row.meatYield) }}</template>
- </el-table-column>
- </el-table>
- <div slot="footer">
- <el-button @click="detailOpen = false">{close}</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import {{ listMeatYieldBatch, listMeatYieldDetail }} from '@/api/production/meatYieldAnalysis'
- export default {{
- name: 'MeatYieldAnalysis',
- data() {{
- return {{
- loading: false,
- detailLoading: false,
- showSearch: true,
- total: 0,
- batchList: [],
- detailList: [],
- detailOpen: false,
- detailTitle: '',
- entranceTimeRange: [],
- queryParams: {{
- pageNum: 1,
- pageSize: 10,
- beginEntranceTime: undefined,
- endEntranceTime: undefined
- }},
- currentBatch: null
- }}
- }},
- created() {{
- this.getList()
- }},
- methods: {{
- formatWeight(val) {{
- if (val === null || val === undefined || val === '') return '-'
- const n = Number(val)
- return isNaN(n) ? val : n.toFixed(2)
- }},
- formatPercent(val) {{
- if (val === null || val === undefined || val === '') return '-'
- const n = Number(val)
- return isNaN(n) ? val : n.toFixed(2)
- }},
- buildTimeParams() {{
- if (this.entranceTimeRange && this.entranceTimeRange.length === 2) {{
- this.queryParams.beginEntranceTime = this.entranceTimeRange[0] + ' 00:00:00'
- this.queryParams.endEntranceTime = this.entranceTimeRange[1] + ' 23:59:59'
- }} else {{
- this.queryParams.beginEntranceTime = undefined
- this.queryParams.endEntranceTime = undefined
- }}
- }},
- getList() {{
- this.loading = true
- this.buildTimeParams()
- listMeatYieldBatch(this.queryParams).then(res => {{
- this.batchList = res.rows || []
- this.total = res.total || 0
- this.loading = false
- }}).catch(() => {{
- this.loading = false
- }})
- }},
- handleQuery() {{
- this.queryParams.pageNum = 1
- this.getList()
- }},
- resetQuery() {{
- this.entranceTimeRange = []
- this.resetForm('queryForm')
- this.queryParams.pageNum = 1
- this.handleQuery()
- }},
- handleDetail(row) {{
- this.currentBatch = row
- this.detailTitle = '{detail_title}' + (row.entranceBatchNo || '')
- this.detailOpen = true
- this.detailLoading = true
- listMeatYieldDetail({{ entranceBatchId: row.entranceBatchId }}).then(res => {{
- this.detailList = res.rows || []
- this.detailLoading = false
- }}).catch(() => {{
- this.detailLoading = false
- }})
- }}
- }}
- }}
- </script>
- '''.format(**LABELS)
- os.makedirs(os.path.dirname(OUT), exist_ok=True)
- with open(OUT, "w", encoding="utf-8", newline="\n") as f:
- f.write(CONTENT)
- print("Wrote", OUT)
|