From f838ba8728a8b992b1039c29b18c595fcb2ede8d Mon Sep 17 00:00:00 2001
From: Fixiaobai <fixiaobai@163.com>
Date: 星期一, 06 十一月 2023 10:53:44 +0800
Subject: [PATCH] new file: src/api/equipment/metering.js new file: src/views/equipment/metering/index.vue new file: src/views/equipment/metering/metering-form.vue
---
src/views/equipment/metering/metering-form.vue | 201 ++++++++++++++++++++++
src/views/equipment/metering/index.vue | 268 +++++++++++++++++++++++++++++
src/api/equipment/metering.js | 53 +++++
3 files changed, 522 insertions(+), 0 deletions(-)
diff --git a/src/api/equipment/metering.js b/src/api/equipment/metering.js
new file mode 100644
index 0000000..24d7552
--- /dev/null
+++ b/src/api/equipment/metering.js
@@ -0,0 +1,53 @@
+import request from '@/router/axios'
+
+export function fetchList(query) {
+ return request({
+ url: '/mes/equipmentDevice/page',
+ method: 'get',
+ params: query
+ })
+}
+
+export function pullEquip() {
+ return request({
+ url: '/mes/equipmentDevice/updateDevicd',
+ method: 'post',
+ })
+}
+
+export function addObj(obj) {
+ return request({
+ url: '/mes/equipmentDevice/addDevicd',
+ method: 'post',
+ data: obj
+ })
+}
+
+export function getObj(id) {
+ return request({
+ url: '/mes/equipmentDevice/' + id,
+ method: 'get'
+ })
+}
+
+export function delObj(id) {
+ return request({
+ url: '/mes/equipmentDevice/' + id,
+ method: 'delete'
+ })
+}
+
+export function putObj(obj) {
+ return request({
+ url: '/mes/equipmentDevice/updateDevicd',
+ method: 'post',
+ data: obj
+ })
+}
+
+export function getEquipmentPageByWorkstation(id) {
+ return request({
+ url: '/mes/equipmentDevice/page/' + id,
+ method: 'get'
+ })
+}
\ No newline at end of file
diff --git a/src/views/equipment/metering/index.vue b/src/views/equipment/metering/index.vue
new file mode 100644
index 0000000..bbc96a2
--- /dev/null
+++ b/src/views/equipment/metering/index.vue
@@ -0,0 +1,268 @@
+<template>
+ <div class="mod-config">
+ <basic-container>
+ <ttable
+ :table="table"
+ @handleSelectionChange="handleSelectionChange"
+ :uploadInfo="uploadInfo"
+ :prelang="prelang"
+ :options="options"
+ :ajaxFun="ajaxFun"
+ ref="equipmentTable"
+ >
+ <template #toolbar></template>
+ </ttable>
+ <!-- 寮圭獥, 鏂板 / 淇敼 -->
+ <table-form
+ v-if="addOrUpdateVisible"
+ ref="addOrUpdate"
+ @refreshDataList="getData"
+ ></table-form>
+ </basic-container>
+ </div>
+ </template>
+
+ <script>
+ import { delObj, fetchList,pullEquip } from '@/api/equipment/metering'
+ import TableForm from './metering-form'
+ import ttable from '@/views/common/ztt-table.vue'
+ import { mapGetters } from 'vuex'
+ import * as fecha from 'element-ui/lib/utils/date'
+ import { remote } from '../../../api/admin/dict'
+ export default {
+ data() {
+ return {
+ ajaxFun: fetchList,
+ multipleSelection: [],
+ uploadInfo: {
+ // 鏄惁灞曠ず涓婁紶EXCEL浠ュ強瀵瑰簲鐨剈rl
+ isShow: true,
+ url: '/mes/equipment/upload'
+ },
+ prelang: 'workstation',
+ options: {
+ height: 300, // 榛樿楂樺害-涓轰簡琛ㄥご鍥哄畾
+ stripe: true, // 鏄惁涓烘枒椹汗 table
+ highlightCurrentRow: false, // 鏄惁瑕侀珮浜綋鍓嶈
+ border: true, // 鏄惁鏈夌旱鍚戣竟妗�
+ lazy: false, // 鏄惁闇�瑕佹噿鍔犺浇
+ fit: true, // 鍒楃殑瀹藉害鏄惁鑷拺寮�
+ multiSelect: true, //
+ seqNo: true,
+ isRefresh: true, // 鏄惁鏄剧ず鍒锋柊鎸夐挳
+ isShowHide: true, // 鏄惁鏄剧ず鏄惧奖鎸夐挳
+ isSearch: false, // 楂樼骇鏌ヨ鎸夐挳
+ defaultOrderBy: { column: 'manufactureDate', direction: 'desc' }
+ },
+ table: {
+ total: 0,
+ currentPage: 1,
+ pageSize: 20,
+ data: [],
+ // 鏍囬
+ column: [
+ // 璁惧缂栧彿
+ {
+ minWidth: '30',
+ prop: 'code',
+ label: '璁惧缂栧彿',
+ sort: true,
+ isTrue: true,
+ formatter: (row, column, cellValue) => {
+ return cellValue
+ },
+ isSearch: true,
+ searchInfoType: 'text'
+ },
+ // 璁惧鍚嶇О
+ {
+ minWidth: '30',
+ prop: 'name',
+ label: '璁惧鍚嶇О',
+ sort: true,
+ isTrue: true,
+ isSearch: true,
+ searchInfoType: 'text'
+ },
+ // 宸ュ巶
+ // {
+ // minWidth: '30',
+ // prop: 'factoryName',
+ // label: '宸ュ巶',
+ // sort: true,
+ // isTrue: true,
+ // isSearch: true,
+ // searchInfoType: 'text'
+ // },
+ {
+ minWidth: '30',
+ prop: 'type',
+ label: '璁惧绫诲瀷',
+ // sort: true,
+ isTrue: true,
+ isSearch: true,
+ // searchInfoType: 'select',
+ formatter: this.workShopFormatter,
+ // optList: () => {
+ // return this.workshopList
+ // }
+ },
+ // 鍨嬪彿瑙勬牸
+ {
+ minWidth: '30',
+ prop: 'supplier',
+ label: '鍘傚',
+ sort: true,
+ isTrue: true,
+ isSearch: false,
+ searchInfoType: 'text'
+ },
+ // 鐘舵��
+ {
+ minWidth: '30',
+ prop: 'status',
+ label: '鐘舵��',
+ sort: true,
+ isTrue: true,
+ isSearch: true,
+ searchInfoType: 'text'
+ },
+ // 鍒堕�犳棩鏈�
+ {
+ minWidth: '150',
+ width: '250',
+ prop: 'createTime',
+ label: '鍒涘缓鏃堕棿',
+ sort: true,
+ isTrue: true,
+ formatter: this.formatReceiveTime,
+ isSearch: true,
+ searchInfoType: 'datetime'
+ },
+
+ {
+ minWidth: '150',
+ width: '250',
+ prop: 'updateTime',
+ label: '淇敼鏃堕棿',
+ sort: true,
+ isTrue: true,
+ formatter: this.formatReceiveTime,
+ isSearch: true,
+ searchInfoType: 'datetime'
+ },
+ ],
+ toolbar: [
+ {
+ text: '鏂板',
+ type: 'primary',
+ fun: this.addOrUpdateHandle
+ },
+ // {
+ // text: '鍚屾',
+ // type: 'primary',
+ // loading: false,
+ // fun: this.pullEquipFun
+ // }
+ ],
+ operator: [
+ {
+ text: '淇敼',
+ icon: 'el-icon-edit',
+ type: 'text',
+ size: 'small',
+ fun: this.addOrUpdateHandle
+ },
+ {
+ text: '鍒犻櫎',
+ icon: 'el-icon-delete',
+ type: 'text',
+ size: 'small',
+ fun: this.deleteHandle
+ }
+ ],
+ operatorConfig: {
+ fixed: 'right',
+ label: '鎿嶄綔',
+ width: 130,
+ minWidth: 130
+ }
+ },
+ addOrUpdateVisible: false,
+ workshopList: []
+ }
+ },
+ components: {
+ ttable,
+ TableForm
+ },
+ computed: {
+ ...mapGetters(['permissions'])
+ },
+ created() {
+ remote('work_shop').then((response) => {
+ if (response.data.code === 0) {
+ this.workshopList = response.data.data
+ } else {
+ this.workshopList = []
+ }
+ })
+ },
+ methods: {
+ pullEquipFun(){
+ this.table.toolbar.find((e) => e.text === '鍚屾').loading = true
+ pullEquip().then(res=>{
+ this.$message.success(res.data.data.msg)
+ this.table.toolbar.find((e) => e.text === '鍚屾').loading = false
+ }).catch(error=>{
+ this.$message.error("鍚屾澶辫触",error)
+ this.getData()
+ this.table.toolbar.find((e) => e.text === '鍚屾').loading = false
+ })
+ },
+ workShopFormatter(row, column, cellValue) {
+ if(cellValue==='鍘熸潗鏂欐楠�'){
+ cellValue=="鍘熸潗鏂欐楠�"
+ }
+ if(cellValue==='杩囩▼妫�楠�'){
+ cellValue=="杩囩▼妫�楠�"
+ }
+ return cellValue
+ },
+ // 鑾峰彇鏁版嵁鍒楄〃
+ getData() {
+ this.$refs.equipmentTable.getDataList()
+ },
+ formatReceiveTime(row, column, cellValue) {
+ return cellValue ? fecha.format(new Date(cellValue), 'yyyy-MM-dd HH:mm:ss') : ''
+ },
+ handleSelectionChange(val) {
+ this.multipleSelection = val
+ },
+ // 鏂板 / 淇敼
+ addOrUpdateHandle(row) {
+ this.addOrUpdateVisible = true
+ this.$nextTick(() => {
+ this.$refs.addOrUpdate.init(row == null ? null : row.id)
+ })
+ },
+ // 鍒犻櫎
+ deleteHandle(row) {
+ this.$confirm('鏄惁纭鍒犻櫎璁惧鍚嶇О涓�' + row.name, '鎻愮ず', {
+ confirmButtonText: '纭畾',
+ cancelButtonText: '鍙栨秷',
+ closeOnClickModal: false,
+ type: 'warning'
+ })
+ .then(function() {
+ return delObj(row.id)
+ })
+ .then((data) => {
+ this.$message.success('鍒犻櫎鎴愬姛')
+ this.getData()
+ })
+ }
+ }
+ }
+ </script>
+
\ No newline at end of file
diff --git a/src/views/equipment/metering/metering-form.vue b/src/views/equipment/metering/metering-form.vue
new file mode 100644
index 0000000..1d290dd
--- /dev/null
+++ b/src/views/equipment/metering/metering-form.vue
@@ -0,0 +1,201 @@
+<template>
+ <el-dialog
+ :title="!dataForm.id ? '鏂板' : '淇敼'"
+ :close-on-click-modal="false"
+ :visible.sync="visible"
+ >
+ <el-form
+ :model="dataForm"
+ :rules="dataRule"
+ ref="dataForm"
+ label-width="80px"
+ class="l-mes"
+ >
+ <el-row>
+ <el-col :span="12">
+ <el-form-item label="缂栧彿" prop="code">
+ <el-input v-model="dataForm.code" placeholder="缂栧彿"></el-input>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="鍚嶇О" prop="name">
+ <el-input v-model="dataForm.name" placeholder="鍚嶇О"></el-input>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="绫诲瀷" prop="type">
+ <el-select
+ v-model="dataForm.type"
+ filterable
+ placeholder="璇烽�夋嫨"
+ style="width:100%"
+ >
+ <el-option
+ v-for="item in workshopList"
+ :key="item.id"
+ :label="item.label"
+ :value="item.value"
+ >
+ </el-option>
+ </el-select>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="鍘傚" prop="supplier">
+ <el-input
+ v-model="dataForm.supplier"
+ placeholder="鍘傚"
+ ></el-input>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="鐘舵��" prop="state">
+ <el-select
+ v-model="dataForm.status"
+ placeholder="鐘舵��"
+ filterable
+ style="width: 100%"
+ >
+ <el-option
+ v-for="item in equipmentState"
+ :key="item.id"
+ :label="item.label"
+ :value="item.label"
+ />
+ </el-select>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ </el-form>
+ <span slot="footer" class="dialog-footer">
+ <el-button @click="visible = false">鍙栨秷</el-button>
+ <el-button
+ type="primary"
+ :disabled="isSubmit"
+ v-thinclick="`dataFormSubmit`"
+ >纭畾</el-button
+ >
+ </span>
+ </el-dialog>
+ </template>
+ <script>
+ import { getObj, addObj, putObj } from '@/api/equipment/metering'
+ import { loadFactoryList } from '@/api/basic/factory'
+ import { remote } from '../../../api/admin/dict'
+ export default {
+ data() {
+ return {
+ // options: regionData,
+ visible: false,
+ dataForm: {
+ id: 0,
+ number: '',
+ name: '',
+ factoryId: '',
+ workshop: '',
+ position: '',
+ email: '',
+ supplier: '',
+ manufacturer: '',
+ typeSpecification: '',
+ manufactureDate: '',
+ installDate: '',
+ state: '',
+ description: '',
+ value1: '',
+ code: null,
+ type: null,
+ status: null,
+ supplier: null
+ },
+ dataRule: {
+ number: [{ required: true, message: '缂栧彿涓嶈兘涓虹┖', trigger: 'blur' }],
+ name: [{ required: true, message: '鍚嶇О涓嶈兘涓虹┖', trigger: 'blur' }]
+ },
+ factoryOptions: [],
+ equipmentState: [],
+ isSubmit: false,
+ workshopList: [{
+ label: "鍘熸潗鏂欐楠�",
+ value: '鍘熸潗鏂欐楠�'
+ },{
+ label: '杩囩▼妫�楠�',
+ value: '杩囩▼妫�楠�'
+ }]
+ }
+ },
+ methods: {
+ init(id) {
+ this.dataForm.id = id || 0
+ this.visible = true
+ this.$nextTick(() => {
+ this.$refs.dataForm.resetFields()
+ if (this.dataForm.id) {
+ getObj(this.dataForm.id).then((response) => {
+ this.dataForm = response.data.data
+ })
+ } else {
+ if (this.factoryOptions.length > 0) {
+ this.dataForm.factoryId = this.factoryOptions[0].id
+ }
+ }
+ })
+ },
+ // 琛ㄥ崟鎻愪氦
+ getEquipmentState() {
+ remote('equipment_state').then((response) => {
+ if (response.data.code === 0) {
+ this.equipmentState = response.data.data
+ }
+ })
+ },
+ dataFormSubmit() {
+ this.isSubmit = true
+ this.$refs.dataForm.validate((valid) => {
+ if (valid) {
+ if (this.dataForm.id) {
+ putObj(this.dataForm).then((data) => {
+ this.$message.success('淇敼鎴愬姛')
+ this.visible = false
+ this.isSubmit = false
+ this.$emit('refreshDataList')
+ })
+ } else {
+ addObj(this.dataForm).then((data) => {
+ this.$message.success('娣诲姞鎴愬姛')
+ this.visible = false
+ this.isSubmit = false
+ this.$emit('refreshDataList')
+ })
+ }
+ } else {
+ this.isSubmit = false
+ }
+ })
+ },
+
+ initFactorySelect() {
+ loadFactoryList().then((res) => {
+ this.factoryOptions = res.data
+ if (this.factoryOptions.length > 0) {
+ this.dataForm.factoryId = this.factoryOptions[0].id
+ }
+ })
+ }
+ },
+
+ created() {
+ this.initFactorySelect()
+ this.getEquipmentState()
+
+ // remote('work_shop').then((response) => {
+ // if (response.data.code === 0) {
+ // this.workshopList = response.data.data
+ // } else {
+ // this.workshopList = []
+ // }
+ // })
+ }
+ }
+ </script>
+
\ No newline at end of file
--
Gitblit v1.9.3