plm前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

333 lines
9.2 KiB

7 months ago
7 months ago
7 months ago
7 months ago
2 years ago
7 months ago
7 months ago
7 months ago
  1. <script>
  2. import {selectCollectRecordList} from "../../../api/cdc/collect";
  3. const tableId = "2000003"
  4. const table1 = tableId + "Table1"
  5. const tableName = "数据采集历史"
  6. export default {
  7. name: "collectRecord",
  8. props:{
  9. height:{
  10. type:Number,
  11. default:700
  12. },
  13. component:{
  14. type:Boolean,
  15. default:false
  16. }
  17. },
  18. data(){
  19. return{
  20. // 遮罩层
  21. loading: false,
  22. // 导出
  23. exportData: [],
  24. exportName: '数据采集历史' + this.dayjs().format('YYYYMMDDHHmmss'),
  25. exportHeader: [],
  26. exportFooter: [],
  27. // 设备信息表格数据
  28. infoList: [],
  29. // 弹出层标题
  30. title: "数据采集历史",
  31. // 是否显示弹出层
  32. open: false,
  33. // 查询参数
  34. queryParams: {
  35. deviceNo: '',
  36. deviceDesc: null,
  37. deviceType: "",
  38. startDate: "",
  39. endDate: "",
  40. },
  41. collectRecordColumns:[
  42. {
  43. userId: this.$store.state.user.name,
  44. functionId: tableId,
  45. serialNumber: `${table1}CreateTime`,
  46. tableId: table1,
  47. tableName: tableName,
  48. columnProp: 'createTime',
  49. headerAlign: 'center',
  50. align: 'center',
  51. columnLabel: '录入时间',
  52. columnHidden: false,
  53. columnImage: false,
  54. columnSortable: false,
  55. sortLv: 0,
  56. status: true,
  57. fixed: '',
  58. columnWidth: 120
  59. },{
  60. userId: this.$store.state.user.name,
  61. functionId: tableId,
  62. serialNumber: `${table1}DeviceNo`,
  63. tableId: table1,
  64. tableName: tableName,
  65. columnProp: 'deviceNo',
  66. headerAlign: 'center',
  67. align: 'left',
  68. columnLabel: '设备号',
  69. columnHidden: false,
  70. columnImage: false,
  71. columnSortable: false,
  72. sortLv: 0,
  73. status: true,
  74. fixed: '',
  75. columnWidth: 100
  76. },{
  77. userId: this.$store.state.user.name,
  78. functionId: tableId,
  79. serialNumber: `${table1}DeviceDesc`,
  80. tableId: table1,
  81. tableName: tableName,
  82. columnProp: 'deviceDesc',
  83. headerAlign: 'center',
  84. align: 'left',
  85. columnLabel: '设备描述',
  86. columnHidden: false,
  87. columnImage: false,
  88. columnSortable: false,
  89. sortLv: 0,
  90. status: true,
  91. fixed: '',
  92. columnWidth: 120
  93. },{
  94. userId: this.$store.state.user.name,
  95. functionId: tableId,
  96. serialNumber: `${table1}CollectId`,
  97. tableId: table1,
  98. tableName: tableName,
  99. columnProp: 'collectId',
  100. headerAlign: 'center',
  101. align: 'left',
  102. columnLabel: '数据标识ID',
  103. columnHidden: false,
  104. columnImage: false,
  105. columnSortable: false,
  106. sortLv: 0,
  107. status: true,
  108. fixed: '',
  109. columnWidth: 100
  110. },{
  111. userId: this.$store.state.user.name,
  112. functionId: tableId,
  113. serialNumber: `${table1}CollectDesc`,
  114. tableId: table1,
  115. tableName: tableName,
  116. columnProp: 'collectDesc',
  117. headerAlign: 'center',
  118. align: 'left',
  119. columnLabel: '数据标识描述',
  120. columnHidden: false,
  121. columnImage: false,
  122. columnSortable: false,
  123. sortLv: 0,
  124. status: true,
  125. fixed: '',
  126. columnWidth: 120
  127. },{
  128. userId: this.$store.state.user.name,
  129. functionId: tableId,
  130. serialNumber: `${table1}ItemValue`,
  131. tableId: table1,
  132. tableName: tableName,
  133. columnProp: 'itemValue',
  134. headerAlign: 'center',
  135. align: 'right',
  136. columnLabel: '数据实测值',
  137. columnHidden: false,
  138. columnImage: false,
  139. columnSortable: false,
  140. sortLv: 0,
  141. status: true,
  142. fixed: '',
  143. columnWidth: 120
  144. },
  145. ],
  146. }
  147. },
  148. computed: {
  149. tableHeight () {
  150. const base = Number(this.height) || 0
  151. if (!base) {
  152. return 420
  153. }
  154. const adjusted = base - 180
  155. if (adjusted < 320) {
  156. return 320
  157. }
  158. if (adjusted > 420) {
  159. return 420
  160. }
  161. return adjusted
  162. }
  163. },
  164. methods:{
  165. handleQuery(){
  166. let params = {
  167. ...this.queryParams,
  168. site:this.$store.state.user.site,
  169. }
  170. this.loading = true
  171. this.infoList = []
  172. selectCollectRecordList(params).then(({data})=>{
  173. if (data && data.code === 0){
  174. this.infoList = data.rows
  175. }else {
  176. this.$message.warning(data.msg)
  177. }
  178. this.loading = false
  179. }).catch(error=>{
  180. this.loading = false
  181. this.$message.error(error)
  182. })
  183. },
  184. async createExportData () {
  185. if (!this.infoList.length) {
  186. this.$message.warning('请先查询出数据')
  187. return []
  188. }
  189. const params = {
  190. ...this.queryParams,
  191. site: this.$store.state.user.site,
  192. page: 1,
  193. limit: -1
  194. }
  195. this.exportName = '数据采集历史' + this.dayjs().format('YYYYMMDDHHmmss')
  196. try {
  197. const { data } = await selectCollectRecordList(params)
  198. if (data && data.code === 0) {
  199. const rows = data.rows || (data.page && data.page.list) || []
  200. if (!rows.length) {
  201. this.$message.warning('无可导出的数据')
  202. return []
  203. }
  204. this.exportData = rows
  205. return this.exportData
  206. }
  207. this.$message.error(data ? data.msg : '导出失败')
  208. } catch (error) {
  209. this.$message.error(error)
  210. }
  211. return []
  212. },
  213. startDownload () {},
  214. finishDownload () {},
  215. fields () {
  216. const mapping = {}
  217. this.collectRecordColumns.forEach(item => {
  218. if (!item.columnHidden) {
  219. mapping[item.columnLabel] = item.columnProp
  220. }
  221. })
  222. return mapping
  223. }
  224. },
  225. watch:{
  226. "queryParams.deviceNo"(newVal, oldVal){
  227. this.queryParams.deviceNo = newVal.toUpperCase()
  228. }
  229. },
  230. created() {
  231. //this.handleQuery();
  232. },
  233. mounted() {
  234. this.$nextTick(() => {
  235. this.height = window.innerHeight - 225;
  236. })
  237. },
  238. }
  239. </script>
  240. <template>
  241. <div class="app-container">
  242. <el-form :model="queryParams" label-position="top" ref="queryForm" :inline="true" label-width="68px">
  243. <el-form-item label="设备类型" prop="deviceType">
  244. <el-select v-model="queryParams.deviceType" placeholder="请选择设备类型" >
  245. <el-option label="全部" value=""/>
  246. <el-option label="涂布机器-大线" value="涂布机器-大线"/>
  247. <el-option label="涂布机器-小线" value="涂布机器-小线"/>
  248. <el-option label="涂布机器-浓度-大线" value="涂布机器-浓度-大线"/>
  249. <el-option label="涂布机器-浓度-小线" value="涂布机器-浓度-小线"/>
  250. <el-option label="配胶间设备" value="配胶间设备"/>
  251. </el-select>
  252. </el-form-item>
  253. <el-form-item label="设备号" prop="deviceNo">
  254. <el-input
  255. v-model="queryParams.deviceNo"
  256. placeholder=" "
  257. clearable
  258. />
  259. </el-form-item>
  260. <el-form-item label="设备描述" prop="deviceDesc">
  261. <el-input
  262. v-model="queryParams.deviceDesc"
  263. style="width: 200px"
  264. placeholder=" "
  265. clearable
  266. />
  267. </el-form-item>
  268. <el-form-item label="采集日期" prop="startDate">
  269. <el-date-picker
  270. type="date"
  271. style="width: 100%"
  272. value-format="yyyy-MM-dd"
  273. v-model="queryParams.startDate"
  274. placeholder=" "
  275. />
  276. </el-form-item>
  277. <el-form-item label=" ">
  278. <i class="el-icon-right"></i>
  279. </el-form-item>
  280. <el-form-item label=" " prop="endDate">
  281. <el-date-picker
  282. type="date"
  283. style="width: 100%"
  284. v-model="queryParams.endDate"
  285. value-format="yyyy-MM-dd"
  286. placeholder=" "
  287. />
  288. </el-form-item>
  289. <el-form-item label=" ">
  290. <el-button type="primary" @click="handleQuery" plain>查询</el-button>
  291. <download-excel
  292. class="el-button el-button--primary el-button--medium"
  293. :fields="fields()"
  294. :data="exportData"
  295. type="xls"
  296. :name="exportName"
  297. :header="exportHeader"
  298. :footer="exportFooter"
  299. :fetch="createExportData"
  300. :before-generate="startDownload"
  301. :before-finish="finishDownload">
  302. 导出
  303. </download-excel>
  304. </el-form-item>
  305. </el-form>
  306. <el-table v-loading="loading" border :data="infoList">
  307. <el-table-column
  308. v-for="(item,index) in collectRecordColumns" :key="index"
  309. :sortable="item.columnSortable"
  310. :height="height"
  311. :prop="item.columnProp"
  312. :header-align="item.headerAlign"
  313. :show-overflow-tooltip="item.showOverflowTooltip"
  314. :align="item.align"
  315. :fixed="item.fixed === ''?false:item.fixed"
  316. :min-width="item.columnWidth"
  317. :label="item.columnLabel">
  318. <template slot-scope="scope">
  319. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  320. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  321. </template>
  322. </el-table-column>
  323. </el-table>
  324. </div>
  325. </template>
  326. <style scoped>
  327. </style>