西藏巴青项目

index.vue 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <div class="app-container">
  3. <el-card shadow="never">
  4. <el-form ref="queryForm" :model="queryParams" size="small" :inline="true">
  5. <el-form-item prop="keyword">
  6. <template slot="label">{{ lfT("queryYakNo") }}</template>
  7. <el-input
  8. v-model="queryParams.keyword"
  9. :placeholder="lfT('queryYakNoPh')"
  10. clearable
  11. style="width: 200px"
  12. @keyup.enter.native="handleQuery"
  13. />
  14. </el-form-item>
  15. <el-form-item prop="assetStatus">
  16. <template slot="label">{{ lfT("queryAssetStatus") }}</template>
  17. <el-select v-model="queryParams.assetStatus" :placeholder="lfCommon('pleaseSelect')" clearable style="width: 140px">
  18. <el-option v-for="item in assetStatusOptions" :key="item.value" :label="item.label" :value="item.value" />
  19. </el-select>
  20. </el-form-item>
  21. <el-form-item>
  22. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{ lfCommon("search") }}</el-button>
  23. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ lfCommon("reset") }}</el-button>
  24. <el-button
  25. v-hasPermi="['dataModel:yakAsset:sync']"
  26. type="warning"
  27. plain
  28. icon="el-icon-refresh"
  29. size="mini"
  30. :loading="syncing"
  31. @click="handleSync"
  32. >{{ lfT("btnSync") }}</el-button>
  33. </el-form-item>
  34. </el-form>
  35. <div v-if="lastSyncHint" class="yak-list__sync-hint">{{ lastSyncHint }}</div>
  36. </el-card>
  37. <br />
  38. <el-card shadow="never">
  39. <el-table v-loading="loading" :data="tableList" border>
  40. <el-table-column :label="lfT('colYakNo')" prop="yakNo" align="center" min-width="120" :show-overflow-tooltip="true" />
  41. <el-table-column :label="lfT('colPastureName')" prop="pastureName" align="center" min-width="120" :show-overflow-tooltip="true" />
  42. <el-table-column :label="lfT('colGender')" prop="gender" align="center" width="70" />
  43. <el-table-column :label="lfT('colAgeMonths')" align="center" width="80">
  44. <template slot-scope="scope">{{ formatAgeMonths(scope.row.ageMonths) }}</template>
  45. </el-table-column>
  46. <el-table-column :label="lfT('colRealtimeTemp')" align="center" width="100">
  47. <template slot-scope="scope">{{ formatWithUnit(scope.row.realtimeTemp, lfCommon('unitCelsius')) }}</template>
  48. </el-table-column>
  49. <el-table-column :label="lfT('colRealtimeSteps')" align="center" width="100">
  50. <template slot-scope="scope">{{ formatWithUnit(scope.row.realtimeSteps, lfCommon('unitStep')) }}</template>
  51. </el-table-column>
  52. <el-table-column :label="lfT('colAssetStatus')" align="center" width="90">
  53. <template slot-scope="scope">
  54. <el-tag :type="assetStatusTagType(scope.row.assetStatus)" size="small">{{ assetStatusLabel(scope.row.assetStatus) }}</el-tag>
  55. </template>
  56. </el-table-column>
  57. <el-table-column :label="lfT('colStatusChangeDate')" prop="statusChangeDate" align="center" width="110" />
  58. <el-table-column :label="lfCommon('colOp')" align="center" width="80" fixed="right">
  59. <template slot-scope="scope">
  60. <el-button v-hasPermi="['dataModel:yakAsset:query']" type="text" size="mini" @click="handleView(scope.row)">{{ lfCommon("view") }}</el-button>
  61. </template>
  62. </el-table-column>
  63. </el-table>
  64. <pagination
  65. v-show="total > 0"
  66. :total="total"
  67. :page.sync="queryParams.pageNum"
  68. :limit.sync="queryParams.pageSize"
  69. @pagination="getList"
  70. />
  71. </el-card>
  72. <yak-asset-detail-drawer :visible.sync="detailOpen" :asset-id="detailAssetId" />
  73. </div>
  74. </template>
  75. <script>
  76. import livestockFinanceLocaleMixin from "@/mixins/livestockFinanceLocaleMixin"
  77. import { listYakAsset, syncYakAsset } from "@/api/livestockFinance/yakAsset"
  78. import YakAssetDetailDrawer from "./detailDrawer"
  79. export default {
  80. name: "YakAsset",
  81. components: { YakAssetDetailDrawer },
  82. mixins: [livestockFinanceLocaleMixin],
  83. data() {
  84. return {
  85. lfNs: "yakAsset",
  86. loading: false,
  87. syncing: false,
  88. total: 0,
  89. tableList: [],
  90. lastSyncHint: "",
  91. detailOpen: false,
  92. detailAssetId: undefined,
  93. queryParams: {
  94. pageNum: 1,
  95. pageSize: 20,
  96. keyword: undefined,
  97. assetStatus: undefined
  98. }
  99. }
  100. },
  101. computed: {
  102. assetStatusOptions() {
  103. return Array.from({ length: 11 }, (_, i) => ({
  104. value: i + 1,
  105. label: this.lfT("status" + (i + 1))
  106. }))
  107. }
  108. },
  109. created() {
  110. this.getList()
  111. },
  112. methods: {
  113. assetStatusLabel(status) {
  114. if (status == null || status < 1 || status > 11) {
  115. return this.lfCommon("dash")
  116. }
  117. return this.lfT("status" + status)
  118. },
  119. assetStatusTagType(status) {
  120. if (status === 8 || status === 9 || status === 11) {
  121. return "danger"
  122. }
  123. if (status === 4 || status === 6) {
  124. return "warning"
  125. }
  126. if (status === 1 || status === 2) {
  127. return "success"
  128. }
  129. return "info"
  130. },
  131. formatAgeMonths(val) {
  132. if (val == null || val === "") {
  133. return this.lfCommon("dash")
  134. }
  135. return `${val}${this.lfCommon("unitMonth")}`
  136. },
  137. formatWithUnit(val, unit) {
  138. if (val == null || val === "") {
  139. return this.lfCommon("dash")
  140. }
  141. return `${val}${unit}`
  142. },
  143. getList() {
  144. this.loading = true
  145. listYakAsset(this.queryParams)
  146. .then((res) => {
  147. this.tableList = res.rows || []
  148. this.total = res.total != null ? res.total : 0
  149. })
  150. .finally(() => {
  151. this.loading = false
  152. })
  153. },
  154. handleQuery() {
  155. this.queryParams.pageNum = 1
  156. this.getList()
  157. },
  158. resetQuery() {
  159. this.queryParams.keyword = undefined
  160. this.queryParams.assetStatus = undefined
  161. this.resetForm("queryForm")
  162. this.handleQuery()
  163. },
  164. handleView(row) {
  165. this.detailAssetId = row.id
  166. this.detailOpen = true
  167. },
  168. handleSync() {
  169. this.runSyncWithLoading(() => syncYakAsset())
  170. .then((res) => {
  171. const data = res.data || {}
  172. const msg = this.lfT("syncSummary", {
  173. insert: data.insertCount != null ? data.insertCount : 0,
  174. update: data.updateCount != null ? data.updateCount : 0,
  175. fail: data.failCount != null ? data.failCount : 0
  176. })
  177. this.$modal.msgSuccess(msg)
  178. if (data.syncTime) {
  179. this.lastSyncHint = this.lfT("syncTimeHint", { time: this.parseTime(data.syncTime) })
  180. }
  181. this.getList()
  182. })
  183. .catch(() => {})
  184. }
  185. }
  186. }
  187. </script>
  188. <style scoped>
  189. .yak-list__sync-hint {
  190. margin-top: 8px;
  191. font-size: 12px;
  192. color: #909399;
  193. }
  194. </style>