Нет описания

gen_meat_yield_analysis_vue.py 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. # -*- coding: utf-8 -*-
  2. import os
  3. OUT = os.path.join(
  4. os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
  5. "ruoyi-ui", "src", "views", "production", "meatYieldAnalysis", "index.vue",
  6. )
  7. # Chinese via unicode escapes only
  8. LABELS = {
  9. "entrance_time": "\u5165\u573a\u65f6\u95f4",
  10. "to": "\u81f3",
  11. "start": "\u5f00\u59cb\u65e5\u671f",
  12. "end": "\u7ed3\u675f\u65e5\u671f",
  13. "search": "\u641c\u7d22",
  14. "reset": "\u91cd\u7f6e",
  15. "batch_no": "\u5165\u573a\u6279\u6b21",
  16. "batch_date": "\u6279\u6b21\u5165\u573a\u65e5\u671f",
  17. "gross": "\u6bdb\u91cd(kg)",
  18. "net": "\u51c0\u91cd(kg)",
  19. "avg_yield": "\u5e73\u5747\u51fa\u8089\u7387(%)",
  20. "action": "\u64cd\u4f5c",
  21. "detail": "\u8be6\u60c5",
  22. "individual": "\u4e2a\u4f53\u7f16\u53f7",
  23. "yield": "\u51fa\u8089\u7387(%)",
  24. "close": "\u5173 \u95ed",
  25. "detail_title": "\u6279\u6b21\u51fa\u8089\u7387\u8be6\u60c5 - ",
  26. }
  27. CONTENT = '''<template>
  28. <div class="app-container">
  29. <el-form ref="queryForm" :model="queryParams" :inline="true" size="small" v-show="showSearch" label-width="100px">
  30. <el-form-item label="{entrance_time}">
  31. <el-date-picker
  32. v-model="entranceTimeRange"
  33. type="daterange"
  34. range-separator="{to}"
  35. start-placeholder="{start}"
  36. end-placeholder="{end}"
  37. value-format="yyyy-MM-dd"
  38. style="width: 260px"
  39. />
  40. </el-form-item>
  41. <el-form-item>
  42. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{search}</el-button>
  43. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{reset}</el-button>
  44. </el-form-item>
  45. </el-form>
  46. <el-row :gutter="10" class="mb8">
  47. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" />
  48. </el-row>
  49. <el-table border stripe v-loading="loading" :data="batchList">
  50. <el-table-column label="{batch_no}" prop="entranceBatchNo" align="center" min-width="100" />
  51. <el-table-column label="{batch_date}" prop="entranceTime" align="center" width="170" />
  52. <el-table-column label="{gross}" prop="grossWeight" align="center" width="110">
  53. <template slot-scope="scope">{{ formatWeight(scope.row.grossWeight) }}</template>
  54. </el-table-column>
  55. <el-table-column label="{net}" prop="netWeight" align="center" width="110">
  56. <template slot-scope="scope">{{ formatWeight(scope.row.netWeight) }}</template>
  57. </el-table-column>
  58. <el-table-column label="{avg_yield}" prop="avgMeatYield" align="center" width="130">
  59. <template slot-scope="scope">{{ formatPercent(scope.row.avgMeatYield) }}</template>
  60. </el-table-column>
  61. <el-table-column label="{action}" align="center" width="100" fixed="right">
  62. <template slot-scope="scope">
  63. <el-button type="text" size="mini" icon="el-icon-view" @click="handleDetail(scope.row)">{detail}</el-button>
  64. </template>
  65. </el-table-column>
  66. </el-table>
  67. <pagination
  68. v-show="total > 0"
  69. :total="total"
  70. :page.sync="queryParams.pageNum"
  71. :limit.sync="queryParams.pageSize"
  72. @pagination="getList"
  73. />
  74. <el-dialog
  75. :title="detailTitle"
  76. :visible.sync="detailOpen"
  77. width="900px"
  78. append-to-body
  79. @closed="detailList = []"
  80. >
  81. <el-table border stripe v-loading="detailLoading" :data="detailList" max-height="480">
  82. <el-table-column label="{individual}" prop="individualNo" align="center" min-width="120" />
  83. <el-table-column label="{gross}" prop="grossWeight" align="center" width="110">
  84. <template slot-scope="scope">{{ formatWeight(scope.row.grossWeight) }}</template>
  85. </el-table-column>
  86. <el-table-column label="{net}" prop="netWeight" align="center" width="110">
  87. <template slot-scope="scope">{{ formatWeight(scope.row.netWeight) }}</template>
  88. </el-table-column>
  89. <el-table-column label="{yield}" prop="meatYield" align="center" width="120">
  90. <template slot-scope="scope">{{ formatPercent(scope.row.meatYield) }}</template>
  91. </el-table-column>
  92. </el-table>
  93. <div slot="footer">
  94. <el-button @click="detailOpen = false">{close}</el-button>
  95. </div>
  96. </el-dialog>
  97. </div>
  98. </template>
  99. <script>
  100. import {{ listMeatYieldBatch, listMeatYieldDetail }} from '@/api/production/meatYieldAnalysis'
  101. export default {{
  102. name: 'MeatYieldAnalysis',
  103. data() {{
  104. return {{
  105. loading: false,
  106. detailLoading: false,
  107. showSearch: true,
  108. total: 0,
  109. batchList: [],
  110. detailList: [],
  111. detailOpen: false,
  112. detailTitle: '',
  113. entranceTimeRange: [],
  114. queryParams: {{
  115. pageNum: 1,
  116. pageSize: 10,
  117. beginEntranceTime: undefined,
  118. endEntranceTime: undefined
  119. }},
  120. currentBatch: null
  121. }}
  122. }},
  123. created() {{
  124. this.getList()
  125. }},
  126. methods: {{
  127. formatWeight(val) {{
  128. if (val === null || val === undefined || val === '') return '-'
  129. const n = Number(val)
  130. return isNaN(n) ? val : n.toFixed(2)
  131. }},
  132. formatPercent(val) {{
  133. if (val === null || val === undefined || val === '') return '-'
  134. const n = Number(val)
  135. return isNaN(n) ? val : n.toFixed(2)
  136. }},
  137. buildTimeParams() {{
  138. if (this.entranceTimeRange && this.entranceTimeRange.length === 2) {{
  139. this.queryParams.beginEntranceTime = this.entranceTimeRange[0] + ' 00:00:00'
  140. this.queryParams.endEntranceTime = this.entranceTimeRange[1] + ' 23:59:59'
  141. }} else {{
  142. this.queryParams.beginEntranceTime = undefined
  143. this.queryParams.endEntranceTime = undefined
  144. }}
  145. }},
  146. getList() {{
  147. this.loading = true
  148. this.buildTimeParams()
  149. listMeatYieldBatch(this.queryParams).then(res => {{
  150. this.batchList = res.rows || []
  151. this.total = res.total || 0
  152. this.loading = false
  153. }}).catch(() => {{
  154. this.loading = false
  155. }})
  156. }},
  157. handleQuery() {{
  158. this.queryParams.pageNum = 1
  159. this.getList()
  160. }},
  161. resetQuery() {{
  162. this.entranceTimeRange = []
  163. this.resetForm('queryForm')
  164. this.queryParams.pageNum = 1
  165. this.handleQuery()
  166. }},
  167. handleDetail(row) {{
  168. this.currentBatch = row
  169. this.detailTitle = '{detail_title}' + (row.entranceBatchNo || '')
  170. this.detailOpen = true
  171. this.detailLoading = true
  172. listMeatYieldDetail({{ entranceBatchId: row.entranceBatchId }}).then(res => {{
  173. this.detailList = res.rows || []
  174. this.detailLoading = false
  175. }}).catch(() => {{
  176. this.detailLoading = false
  177. }})
  178. }}
  179. }}
  180. }}
  181. </script>
  182. '''.format(**LABELS)
  183. os.makedirs(os.path.dirname(OUT), exist_ok=True)
  184. with open(OUT, "w", encoding="utf-8", newline="\n") as f:
  185. f.write(CONTENT)
  186. print("Wrote", OUT)