From 8a28b3c54ae2a95789be46a104390b33630dd4fc Mon Sep 17 00:00:00 2001
From: 小小儁爺 <1694218219@qq.com>
Date: 星期二, 05 十一月 2024 10:40:55 +0800
Subject: [PATCH] 1.优化
---
src/views/basicSettings/meterPrice.vue | 1429 ++++++++++++++++++++++++++++++-----------------------------
1 files changed, 722 insertions(+), 707 deletions(-)
diff --git a/src/views/basicSettings/meterPrice.vue b/src/views/basicSettings/meterPrice.vue
index c207fcc..78b3bd2 100644
--- a/src/views/basicSettings/meterPrice.vue
+++ b/src/views/basicSettings/meterPrice.vue
@@ -1,707 +1,722 @@
-<template>
- <div>
- <div class="body" :style="{height:mainHeight+'px'}">
-
- <div class="bodyTopButtonGroup" style="justify-content: space-between">
- <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">鏂板</el-button>
- <!-- <el-button v-waves icon="el-icon-download" @click=" ">瀵煎叆</el-button>-->
- </div>
-
- <div class="bodyTopFormGroup">
- <el-form
- ref="form"
- :model="form"
- label-width="100px"
- inline
- style="display: flex;"
- >
- <div class="elForm">
- <el-form-item label="浜у搧鍚嶇О/缂栫爜" style=" display: flex;">
- <el-select
- v-model="form.partcode"
- filterable
- :popper-append-to-body="false"
- style="width: 200px"
- placeholder="璇烽�夋嫨"
-
- @change="partChange"
- >
- <!-- @focus="getPartSelect"-->
- <el-option
- v-for="item in partArr"
- :key="item.partcode"
- :label="item.partname+'/'+item.partcode"
- :value="item.partcode"
- />
- </el-select>
- </el-form-item>
- <el-form-item
- v-if="mesSetting.route"
- label="宸ヨ壓璺嚎"
- style="display: flex;"
- >
- <el-select
- v-model="form.routecode"
- filterable
- :disabled="form.partcode===''"
- :popper-append-to-body="false"
- style="width: 200px"
- placeholder="璇烽�夋嫨"
- @change="routeChange"
- >
- <el-option
- v-for="item in routeArr"
- :key="item.route_code"
- :label="item.route_name"
- :value="item.route_code"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="鍏宠仈宸ュ簭" style=" display: flex;">
- <el-select
- v-model="form.stepcode"
- :disabled="mesSetting.route?form.routecode==='':form.partcode===''"
- :popper-append-to-body="false"
- style="width: 200px"
- placeholder="璇烽�夋嫨"
- >
- <el-option
- v-for="item in stepArr"
- :key="item.step_code"
- :label="item.step_name"
- :value="item.step_code"
- />
- </el-select>
- </el-form-item>
-
- <!--鎸夊伐搴�-->
- <!-- <el-form-item-->
- <!-- v-if="!mesSetting.route"-->
- <!-- label="宸ヨ壓璺嚎"-->
- <!-- style="display: flex;"-->
- <!-- >-->
- <!-- <el-select-->
- <!-- v-model="form.routecode"-->
- <!-- filterable-->
- <!-- :disabled="form.partcode===''"-->
- <!-- :popper-append-to-body="false"-->
- <!-- style="width: 200px"-->
- <!-- placeholder="璇烽�夋嫨"-->
- <!-- @change="routeChange"-->
- <!-- >-->
- <!-- <el-option-->
- <!-- v-for="item in routeArr"-->
- <!-- :key="item.route_code"-->
- <!-- :label="item.route_name"-->
- <!-- :value="item.route_code"-->
- <!-- />-->
- <!-- </el-select>-->
- <!-- </el-form-item>-->
-
- </div>
- <div
- class="bodySearchReset"
- :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}"
- >
- <el-button v-waves type="primary" icon="el-icon-search" @click="search">鏌ヨ</el-button>
- <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">閲嶇疆</el-button>
- </div>
- </el-form>
- <div
- class="bodyTopFormExpand"
- />
- </div>
-
- <div class="elTableDiv">
- <!-- <TableColumnSettings-->
- <!-- :list1="tableColumnSettingsArray"-->
- <!-- @tableColumnUpdate="tableColumnUpdate"-->
- <!-- />-->
- <el-table
- ref="tableDataRef"
- :key="tableTimeStampArrayKey"
- class="tableFixed"
- :data="tableData"
- :height="tableHeight"
- border
- :row-class-name="tableRowClassName"
- :style="{width: 100+'%',height:tableHeight+'px',}"
- highlight-current-row
- :header-cell-style="this.$headerCellStyle"
- :cell-style="this.$cellStyle"
- @sort-change="sortChange"
- >
-
- <el-table-column
- v-for="item in tableColumnSettingsArray"
- v-if="item.show"
- :key="item.id"
- :sortable="item.sortable"
- :prop="item.prop"
- :min-width="item.minWidth"
- :label="item.label"
- :width="item.width"
- show-tooltip-when-overflow
- :fixed="item.fixed?(item.fixed==='left'?'left':'right'):false"
- >
- <template slot-scope="{row}">
- <div v-if="!row[item.prop]">/</div>
- <div v-else-if="item.prop==='eqp_value'||item.prop==='stand_value'">
- {{ row[item.prop] }} 绉�
- </div>
- <div v-else>{{ row[item.prop] }}</div>
- </template>
- </el-table-column>
-
- <el-table-column
- label="鎿嶄綔"
- fixed="right"
- width="120"
- >
- <template slot-scope="{row}">
- <div class="operationClass">
- <el-tooltip class="item" effect="dark" content="缂栬緫" placement="top">
- <i
- :style="{color:$store.state.settings.theme}"
- class="el-icon-edit-outline"
- @click="edit('edit',row)"
- />
- </el-tooltip>
- <el-tooltip v-del-tab-index class="item" effect="dark" content="鍒犻櫎" placement="top">
- <i :style="{color:$store.state.settings.theme}" class="el-icon-delete" @click="del(row)" />
- </el-tooltip>
- </div>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <!--鍒嗛〉-->
- <pagination
- :total="total"
- :page.sync="form.page"
- :limit.sync="form.rows"
- align="right"
- layout="total,prev, pager, next,sizes"
- popper-class="select_bottom"
- @pagination="getBeatRateSearch"
- />
- </div>
-
- <el-dialog
- v-el-drag-dialog
- :title="operation==='add'?'鏂板':'缂栬緫'"
- :visible.sync="dialogVisible"
- width="1100px"
- top="15vh"
- :close-on-click-modal="false"
- @closed="handleClose"
- @close="handleClose"
- >
- <el-form ref="dialogForm" inline :model="dialogForm" label-width="100px">
- <div style="display: flex;align-items: center">
- <i class="el-icon-s-comment" :style="{color:$store.state.settings.theme}" style="margin-top: -20px" />
- <el-form-item prop="partcode" label="浜у搧鍚嶇О/缂栫爜">
- <el-select
- v-show="operation==='add'"
- v-model="dialogForm.partcode"
- filterable
- style="width: 220px"
- placeholder="璇烽�夋嫨"
- :popper-append-to-body="false"
- @change="partDialogChange"
- >
- <!-- @focus="getPartSelect2"-->
- <el-option
- v-for="item in partArr2"
- :key="item.partcode"
- :label="item.partname+'/'+item.partcode"
- :value="item.partcode"
- />
- </el-select>
- <el-input
- v-show="operation!=='add'"
- v-model="editPartName"
- disabled
- style="width: 220px"
- />
- </el-form-item>
- <el-form-item v-if="mesSetting.route" prop="routecode" label="宸ヨ壓璺嚎">
- <el-select
- v-show="operation==='add'"
- v-model="dialogForm.routecode"
- style="width: 220px"
- filterable
- :disabled="dialogForm.partcode===''"
- placeholder="璇烽�夋嫨"
- :popper-append-to-body="false"
- @change="routeDialogChange"
- >
- <el-option
- v-for="item in routeDialogArr"
- :key="item.route_code"
- :label="item.route_name"
- :value="item.route_code"
- />
- </el-select>
- <el-input
- v-show="operation!=='add'"
- v-model="editRouteName"
- disabled
- style="width: 220px"
- />
- </el-form-item>
- </div>
- </el-form>
-
- <el-table
- :data="stepDialogArr"
- style="width: 100%"
- height="300"
- border
- :header-cell-style="this.$headerCellStyle"
- :cell-style="this.$cellStyle"
- :row-class-name="tableRowClassName"
- >
- <el-table-column
- prop="step_seq"
- label="宸ュ簭椤哄簭"
- width="100"
- />
- <el-table-column
- prop="step_code"
- label="宸ュ簭缂栫爜"
- width="200"
- />
- <el-table-column
- prop="step_name"
- label="宸ュ簭鍚嶇О"
- width="200"
- />
- <el-table-column
- prop="unprice"
- label="宸ュ簭宸ヤ环"
- >
- <template slot-scope="{row}">
- <el-input v-model="row.unprice" oninput="value=value.replace(/[^0-9.]/g,'')" />
- </template>
- </el-table-column>
- </el-table>
-
- <span slot="footer" class="dialog-footer">
- <div class="footerButton">
- <el-button v-waves @click="dialogVisibleCancel">杩� 鍥�</el-button>
- <el-button v-waves type="primary" @click="dialogVisibleConfirm">纭� 瀹�</el-button>
- </div>
- </span>
- </el-dialog>
-
- </div>
-</template>
-
-<script>
-import Pagination from '@/components/Pagination'
-import {
- BeatRateSearch, DeleteBeatRate,
- PartSelect,
- PartSelectRpute,
- RouteSelectStep, SaveBeatRate
-} from '@/api/basicSettings'
-import elDragDialog from '@/directive/el-drag-dialog'
-import waves from '@/directive/waves'
-import TableColumnSettings from '@/components/TableColumnSettings'
-
-export default {
- name: 'MeterPrice',
- components: {
- Pagination, TableColumnSettings
- },
- directives: { elDragDialog, waves },
- data() {
- return {
- mesSetting: JSON.parse(localStorage.getItem('mesSetting')),
- mainHeight: 0,
- tableHeight: 0,
- form: {
- partcode: '', // 浜у搧缂栫爜
- routecode: '', // 宸ヨ壓璺嚎缂栫爜
- stepcode: '', // 宸ュ簭缂栫爜
-
- prop: 'partcode', // 鎺掑簭瀛楁
- order: 'desc', // 鎺掑簭瀛楁
- page: 1, // 绗嚑椤�
- rows: 20 // 姣忛〉澶氬皯鏉�
- },
- partArr: [], // 浜у搧闆嗗悎
- partArr2: [], // 浜у搧闆嗗悎瀵硅瘽妗�
- routeArr: [], // 宸ヨ壓璺嚎
- stepArr: [], // 宸ュ簭
-
- total: 10,
- tableData: [],
- tableColumnSettingsArray: [
- // { minWidth: 50, width: false, prop: 'id', label: 'id', id: 1, show: false, fixed: false, sortable: false }, // 闅愯棌鍒� show: false闅愯棌锛宼rue鏄剧ず
- { minWidth: 25, width: 50, prop: 'rowNum', label: '搴忓彿', id: 2, show: true, fixed: 'left', sortable: false }, // custom
- {
- minWidth: 110,
- width: false,
- prop: 'partcode',
- label: '浜у搧缂栫爜',
- id: 3,
- show: true,
- fixed: false,
- sortable: true
- },
- {
- minWidth: 110,
- width: false,
- prop: 'partname',
- label: '浜у搧鍚嶇О',
- id: 4,
- show: true,
- fixed: false,
- sortable: true
- },
- {
- minWidth: 110,
- width: false,
- prop: 'partspec',
- label: '浜у搧瑙勬牸',
- id: 5,
- show: true,
- fixed: false,
- sortable: true
- },
- // {
- // minWidth: 110,
- // width: false,
- // prop: 'wksp_code',
- // label: '鐢熶骇杞﹂棿缂栫爜',
- // id: 6,
- // show: false,
- // fixed: false,
- // sortable: true
- // },
- // {
- // minWidth: false,
- // width: 110,
- // prop: 'wksp_name',
- // label: '鐢熶骇杞﹂棿',
- // id: 7,
- // show: true,
- // fixed: false,
- // sortable: true
- // },
- {
- minWidth: 110,
- width: false,
- prop: 'route_code',
- label: '宸ヨ壓璺嚎缂栫爜',
- id: 8,
- show: false,
- fixed: false,
- sortable: true
- }, {
- minWidth: 110,
- width: false,
- prop: 'route_name',
- label: '宸ヨ壓璺嚎',
- id: 9,
- show: true,
- fixed: false,
- sortable: true
- }, {
- minWidth: 110,
- width: false,
- prop: 'stepcode',
- label: '宸ュ簭缂栫爜',
- id: 10,
- show: false,
- fixed: false,
- sortable: true
- }, {
- minWidth: 110,
- width: false,
- prop: 'stepname',
- label: '宸ュ簭鍚嶇О',
- id: 11,
- show: true,
- fixed: false,
- sortable: true
- },
- {
- minWidth: 110,
- width: false,
- prop: 'unprice',
- label: '璁′欢鍗曚环',
- id: 12,
- show: true,
- fixed: false,
- sortable: true
- },
- {
- minWidth: false,
- width: 110,
- prop: 'lm_user',
- label: '鍒涘缓浜哄憳',
- id: 13,
- show: true,
- fixed: false,
- sortable: true
- },
- {
- minWidth: false,
- width: 160,
- prop: 'lm_date',
- label: '鍒涘缓鏃堕棿',
- id: 14,
- show: true,
- fixed: false,
- sortable: true
- }
-
- ],
- tableTimeStampArrayKey: new Date().getTime(), // 琛ㄦ牸key
- dialogVisible: false,
- dialogForm: {
- partcode: '', // 浜у搧缂栫爜
- routecode: '', // 宸ヨ壓璺嚎缂栫爜
- stepcode: '', // 宸ュ簭缂栫爜
-
- wkshopcode: '', // 鐢熶骇杞﹂棿缂栫爜
- eqp_value: '', // 璁惧鑺傛媿
- stand_value: '', // 鐢熶骇鑺傛媿
- cavity_qty: '', // 鍨嬭厰鏁�
- unprice: ''// 璁′欢鍗曚环
- },
- routeDialogArr: [], // 宸ヨ壓璺嚎
- stepDialogArr: [], // 宸ュ簭闆嗗悎
-
- editPartName: '', // 缂栬緫鏃朵骇鍝佸悕绉�
- editRouteName: '', // 缂栬緫鏃跺伐鑹鸿矾绾垮悕绉�
- editStepName: '', // 缂栬緫鏃跺姞宸ュ伐搴忓悕绉�
- operation: ''
-
- }
- },
-
- activated() {
window.addEventListener('resize', this.getHeight)
this.getHeight()
},
created() {
- this.handleRequest()
- },
- mounted() {
- window.addEventListener('resize', this.getHeight)
- this.getHeight()
-
- if (!this.mesSetting.route) {
- this.tableColumnSettingsArray = this.tableColumnSettingsArray.filter(i => i.prop !== 'route_name')
- }
- },
- methods: {
- tableColumnUpdate(val, isCopyTrue) {
- if (isCopyTrue) {
- this.tableColumnSettingsArray = val
- }
- this.tableTimeStampArrayKey = new Date().getTime()
- this.$refs.tableDataRef.doLayout()
- },
- tableRowClassName({ row, rowIndex }) {
- return 'custom-row'
- },
- handleRequest() {
- this.getBeatRateSearch().then(res => {
- if (res.code === '200') {
- this.getPartSelect()
- }
- })
- },
-
- async getBeatRateSearch() {
- const res = await BeatRateSearch(this.form)
- this.tableData = res.data
- this.total = res.count
- return { code: res.code }
- },
- // 鎺掑簭鏀瑰彉鏃�
- sortChange({ column, prop, order }) {
- if (order === 'descending') {
- order = 'desc'
- } else if (order === 'ascending') {
- order = 'asc'
- } else {
- order = 'desc'
- }
- this.form.order = order
- this.form.prop = prop
- this.getBeatRateSearch()
- },
- // 鏌ヨ
- search() {
- this.getBeatRateSearch()
- },
- async getPartSelect() {
- const { data: res } = await PartSelect()
- this.partArr = res
- },
- async getPartSelect2() {
- const { data: res } = await PartSelect()
- this.partArr2 = res
- },
- async partChange(val) {
- const { data: res } = await PartSelectRpute({ partcode: val })
- if (this.mesSetting.route) {
- this.routeArr = res
- this.form.routecode = ''
- } else {
- this.stepArr = res
- }
- this.form.stepcode = ''
- },
- async routeChange(val) {
- const { data: res } = await RouteSelectStep({ partcode: this.form.partcode, routecode: val })
- this.stepArr = res
- this.form.stepcode = ''
- },
-
- // 閲嶇疆
- reset() {
- this.form.partcode = ''
- this.form.routecode = ''
- this.form.stepcode = ''
- this.getBeatRateSearch()
- },
- async partDialogChange(val) {
- const { data: res } = await PartSelectRpute({ partcode: val })
- if (this.mesSetting.route) {
- this.routeDialogArr = res
- this.stepDialogArr = []
- this.dialogForm.routecode = ''
- } else {
- this.stepDialogArr = res
- }
- },
- async routeDialogChange(val) {
- const { data: res } = await RouteSelectStep({ partcode: this.dialogForm.partcode, routecode: val })
- this.stepDialogArr = res
- },
-
- // 鏂板鎸夐挳
- add(operation) {
- this.operation = operation
- this.dialogVisible = true
- this.getPartSelect2()
- },
- // 淇敼鎸夐挳
- async edit(operation, row) {
- this.operation = operation
- this.dialogVisible = true
-
- this.editPartName = row.partname
- this.editRouteName = row.route_name
- this.editStepName = row.stepname
-
- await this.partDialogChange(row.partcode)
-
- this.dialogForm.partcode = row.partcode
- if (this.mesSetting.route) {
- await this.routeDialogChange(row.route_code)
- }
- this.dialogForm.routecode = row.route_code
- this.dialogForm.stepcode = row.stepcode
- },
- // 鍒犻櫎鎸夐挳
- async del(row) {
- this.$confirm('鏄惁纭鍒犻櫎?', '鎻愮ず', {
- confirmButtonText: '纭畾',
- cancelButtonText: '鍙栨秷',
- type: 'warning'
- }).then(() => {
- DeleteBeatRate({ id: row.id }).then(res => {
- if (res.code === '200') {
- this.$message.success('鍒犻櫎鎴愬姛!')
- if (this.form.page > 1 && this.tableData.length === 1) {
- this.form.page--
- }
- this.getBeatRateSearch()
- }
- })
- }).catch(() => {
- this.$message.info('宸插彇娑堝垹闄�')
- })
- },
- // 瀵硅瘽妗嗗叧闂簨浠�
- handleClose() {
- this.dialogForm.partcode = ''
- this.dialogForm.routecode = ''
- this.dialogForm.stepcode = ''
-
- this.dialogForm.wkshopcode = ''
- this.dialogForm.eqp_value = ''
- this.dialogForm.stand_value = ''
- this.dialogForm.cavity_qty = ''
- this.dialogForm.unprice = ''
- this.eqpTableLength = 0
- this.routeDialogArr = []
- this.stepDialogArr = []
-
- this.$refs.dialogForm.clearValidate()
- this.getBeatRateSearch()
- },
- // 瀵硅瘽妗嗗彇娑�
- dialogVisibleCancel() {
- this.dialogVisible = false
- },
- // 瀵硅瘽妗嗙‘璁�
- dialogVisibleConfirm() {
- this.$refs.dialogForm.validate(valid => {
- if (valid) {
- const children = []
- this.stepDialogArr.forEach(i => {
- children.push({
- 'code': i.step_code,
- 'name': i.step_name,
- 'seq': i.step_seq,
- 'isbott': i.isbott,
- 'isend': i.isend,
- 'unprice': i.unprice
- })
- })
-
- const data = [
- {
- 'partcode': this.dialogForm.partcode,
- 'defaultroute_code': this.dialogForm.routecode,
- 'children': children
- }
- ]
- SaveBeatRate(data).then(res => {
- if (res.code === '200') {
- this.$message.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '淇敼鎴愬姛锛�')
- this.dialogVisible = false
- this.getBeatRateSearch()
- } else {
- this.$message.error(this.operation === 'add' ? '娣诲姞澶辫触锛�' : '淇敼澶辫触锛�')
- }
- })
- }
- })
- },
-
- // 鑾峰彇椤甸潰楂樺害
- getHeight() {
- this.$nextTick(() => {
- this.mainHeight = window.innerHeight - 85
- this.tableHeight = this.mainHeight - 195
- if (window.innerHeight < 769) {
- this.tableHeight = this.tableHeight - 40
- }
- this.$refs.tableDataRef.doLayout()
- })
- }
- }
-}
-</script>
-
-<style>
-.el-table .custom-row {
- background: #f8f8fa;
-}
-</style>
+<template>
+ <div>
+ <div class="body" :style="{height:mainHeight+'px'}">
+
+ <div class="bodyTopButtonGroup" style="justify-content: space-between">
+ <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">鏂板</el-button>
+ <!-- <el-button v-waves icon="el-icon-download" @click=" ">瀵煎叆</el-button>-->
+ </div>
+
+ <div class="bodyTopFormGroup">
+ <el-form
+ ref="form"
+ :model="form"
+ label-width="100px"
+ inline
+ style="display: flex;"
+ >
+ <div class="elForm">
+ <el-form-item label="浜у搧鍚嶇О/缂栫爜" style=" display: flex;">
+ <el-select
+ v-model="form.partcode"
+ filterable
+ :popper-append-to-body="false"
+ style="width: 200px"
+ placeholder="璇烽�夋嫨"
+
+ @change="partChange"
+ >
+ <!-- @focus="getPartSelect"-->
+ <el-option
+ v-for="item in partArr"
+ :key="item.partcode"
+ :label="item.partname+'/'+item.partcode"
+ :value="item.partcode"
+ />
+ </el-select>
+ </el-form-item>
+ <el-form-item
+ v-if="mesSetting.route"
+ label="宸ヨ壓璺嚎"
+ style="display: flex;"
+ >
+ <el-select
+ v-model="form.routecode"
+ filterable
+ :disabled="form.partcode===''"
+ :popper-append-to-body="false"
+ style="width: 200px"
+ placeholder="璇烽�夋嫨"
+ @change="routeChange"
+ >
+ <el-option
+ v-for="item in routeArr"
+ :key="item.route_code"
+ :label="item.route_name"
+ :value="item.route_code"
+ />
+ </el-select>
+ </el-form-item>
+ <el-form-item label="鍏宠仈宸ュ簭" style=" display: flex;">
+ <el-select
+ v-model="form.stepcode"
+ :disabled="mesSetting.route?form.routecode==='':form.partcode===''"
+ :popper-append-to-body="false"
+ style="width: 200px"
+ placeholder="璇烽�夋嫨"
+ >
+ <el-option
+ v-for="item in stepArr"
+ :key="item.step_code"
+ :label="item.step_name"
+ :value="item.step_code"
+ />
+ </el-select>
+ </el-form-item>
+
+ <!--鎸夊伐搴�-->
+ <!-- <el-form-item-->
+ <!-- v-if="!mesSetting.route"-->
+ <!-- label="宸ヨ壓璺嚎"-->
+ <!-- style="display: flex;"-->
+ <!-- >-->
+ <!-- <el-select-->
+ <!-- v-model="form.routecode"-->
+ <!-- filterable-->
+ <!-- :disabled="form.partcode===''"-->
+ <!-- :popper-append-to-body="false"-->
+ <!-- style="width: 200px"-->
+ <!-- placeholder="璇烽�夋嫨"-->
+ <!-- @change="routeChange"-->
+ <!-- >-->
+ <!-- <el-option-->
+ <!-- v-for="item in routeArr"-->
+ <!-- :key="item.route_code"-->
+ <!-- :label="item.route_name"-->
+ <!-- :value="item.route_code"-->
+ <!-- />-->
+ <!-- </el-select>-->
+ <!-- </el-form-item>-->
+
+ </div>
+ <div
+ class="bodySearchReset"
+ :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}"
+ >
+ <el-button v-waves type="primary" icon="el-icon-search" @click="search">鏌ヨ</el-button>
+ <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">閲嶇疆</el-button>
+ </div>
+ </el-form>
+ <div
+ class="bodyTopFormExpand"
+ />
+ </div>
+
+ <div class="elTableDiv">
+ <!-- <TableColumnSettings-->
+ <!-- :list1="tableColumnSettingsArray"-->
+ <!-- @tableColumnUpdate="tableColumnUpdate"-->
+ <!-- />-->
+ <el-table
+ ref="tableDataRef"
+ :key="tableTimeStampArrayKey"
+ class="tableFixed"
+ :data="tableData"
+ :height="tableHeight"
+ border
+ :row-class-name="tableRowClassName"
+ :style="{width: 100+'%',height:tableHeight+'px',}"
+ highlight-current-row
+ :header-cell-style="this.$headerCellStyle"
+ :cell-style="this.$cellStyle"
+ @sort-change="sortChange"
+ >
+
+ <el-table-column
+ v-for="item in tableColumnSettingsArray"
+ v-if="item.show"
+ :key="item.id"
+ :sortable="item.sortable"
+ :prop="item.prop"
+ :min-width="item.minWidth"
+ :label="item.label"
+ :width="item.width"
+ show-tooltip-when-overflow
+ :fixed="item.fixed?(item.fixed==='left'?'left':'right'):false"
+ >
+ <template slot-scope="{row}">
+ <div v-if="!row[item.prop]">/</div>
+ <div v-else-if="item.prop==='eqp_value'||item.prop==='stand_value'">
+ {{ row[item.prop] }} 绉�
+ </div>
+ <div v-else>{{ row[item.prop] }}</div>
+ </template>
+ </el-table-column>
+
+ <el-table-column
+ label="鎿嶄綔"
+ fixed="right"
+ width="120"
+ >
+ <template slot-scope="{row}">
+ <div class="operationClass">
+ <el-tooltip class="item" effect="dark" content="缂栬緫" placement="top">
+ <i
+ :style="{color:$store.state.settings.theme}"
+ class="el-icon-edit-outline"
+ @click="edit('edit',row)"
+ />
+ </el-tooltip>
+ <el-tooltip v-del-tab-index class="item" effect="dark" content="鍒犻櫎" placement="top">
+ <i :style="{color:$store.state.settings.theme}" class="el-icon-delete" @click="del(row)" />
+ </el-tooltip>
+ </div>
+ </template>
+ </el-table-column>
+ </el-table>
+ </div>
+ <!--鍒嗛〉-->
+ <pagination
+ :total="total"
+ :page.sync="form.page"
+ :limit.sync="form.rows"
+ align="right"
+ layout="total,prev, pager, next,sizes"
+ popper-class="select_bottom"
+ @pagination="getBeatRateSearch"
+ />
+ </div>
+
+ <el-dialog
+ v-el-drag-dialog
+ :title="operation==='add'?'鏂板':'缂栬緫'"
+ :visible.sync="dialogVisible"
+ width="1100px"
+ top="15vh"
+ :close-on-click-modal="false"
+ @closed="handleClose"
+ @close="handleClose"
+ >
+ <el-form ref="dialogForm" inline :model="dialogForm" label-width="100px">
+ <div style="display: flex;align-items: center">
+ <i class="el-icon-s-comment" :style="{color:$store.state.settings.theme}" style="margin-top: -20px" />
+ <el-form-item prop="partcode" label="浜у搧鍚嶇О/缂栫爜">
+ <el-select
+ v-show="operation==='add'"
+ v-model="dialogForm.partcode"
+ filterable
+ style="width: 220px"
+ placeholder="璇烽�夋嫨"
+ :popper-append-to-body="false"
+ @change="partDialogChange"
+ >
+ <!-- @focus="getPartSelect2"-->
+ <el-option
+ v-for="item in partArr2"
+ :key="item.partcode"
+ :label="item.partname+'/'+item.partcode"
+ :value="item.partcode"
+ />
+ </el-select>
+ <el-input
+ v-show="operation!=='add'"
+ v-model="editPartName"
+ disabled
+ style="width: 220px"
+ />
+ </el-form-item>
+ <el-form-item v-if="mesSetting.route" prop="routecode" label="宸ヨ壓璺嚎">
+ <el-select
+ v-show="operation==='add'"
+ v-model="dialogForm.routecode"
+ style="width: 220px"
+ filterable
+ :disabled="dialogForm.partcode===''"
+ placeholder="璇烽�夋嫨"
+ :popper-append-to-body="false"
+ @change="routeDialogChange"
+ >
+ <el-option
+ v-for="item in routeDialogArr"
+ :key="item.route_code"
+ :label="item.route_name"
+ :value="item.route_code"
+ />
+ </el-select>
+ <el-input
+ v-show="operation!=='add'"
+ v-model="editRouteName"
+ disabled
+ style="width: 220px"
+ />
+ </el-form-item>
+ </div>
+ </el-form>
+
+ <el-table
+ :data="stepDialogArr"
+ style="width: 100%"
+ height="300"
+ border
+ :header-cell-style="this.$headerCellStyle"
+ :cell-style="this.$cellStyle"
+ :row-class-name="tableRowClassName"
+ >
+ <el-table-column
+ prop="step_seq"
+ label="宸ュ簭椤哄簭"
+ width="100"
+ />
+ <el-table-column
+ prop="step_code"
+ label="宸ュ簭缂栫爜"
+ width="200"
+ />
+ <el-table-column
+ prop="step_name"
+ label="宸ュ簭鍚嶇О"
+ width="200"
+ />
+ <el-table-column
+ prop="unprice"
+ label="宸ュ簭宸ヤ环"
+ >
+ <template slot-scope="{row}">
+ <el-input v-model="row.unprice" oninput="value=value.replace(/[^0-9.]/g,'')" />
+ </template>
+ </el-table-column>
+ </el-table>
+
+ <span slot="footer" class="dialog-footer">
+ <div class="footerButton">
+ <el-button v-waves @click="dialogVisibleCancel">杩� 鍥�</el-button>
+ <el-button v-waves type="primary" @click="dialogVisibleConfirm">纭� 瀹�</el-button>
+ </div>
+ </span>
+ </el-dialog>
+
+ </div>
+</template>
+
+<script>
+import Pagination from '@/components/Pagination'
+import {
+ BeatRateSearch, DeleteBeatRate,
+ PartSelect,
+ PartSelectRpute,
+ RouteSelectStep, SaveBeatRate
+} from '@/api/basicSettings'
+import elDragDialog from '@/directive/el-drag-dialog'
+import waves from '@/directive/waves'
+import TableColumnSettings from '@/components/TableColumnSettings'
+
+export default {
+ name: 'MeterPrice',
+ components: {
+ Pagination, TableColumnSettings
+ },
+ directives: { elDragDialog, waves },
+ data() {
+ return {
+ mesSetting: JSON.parse(localStorage.getItem('mesSetting')),
+ mainHeight: 0,
+ tableHeight: 0,
+ form: {
+ partcode: '', // 浜у搧缂栫爜
+ routecode: '', // 宸ヨ壓璺嚎缂栫爜
+ stepcode: '', // 宸ュ簭缂栫爜
+
+ prop: 'partcode', // 鎺掑簭瀛楁
+ order: 'desc', // 鎺掑簭瀛楁
+ page: 1, // 绗嚑椤�
+ rows: 20 // 姣忛〉澶氬皯鏉�
+ },
+ partArr: [], // 浜у搧闆嗗悎
+ partArr2: [], // 浜у搧闆嗗悎瀵硅瘽妗�
+ routeArr: [], // 宸ヨ壓璺嚎
+ stepArr: [], // 宸ュ簭
+
+ total: 10,
+ tableData: [],
+ tableColumnSettingsArray: [
+ // { minWidth: 50, width: false, prop: 'id', label: 'id', id: 1, show: false, fixed: false, sortable: false }, // 闅愯棌鍒� show: false闅愯棌锛宼rue鏄剧ず
+ { minWidth: 25, width: 50, prop: 'rowNum', label: '搴忓彿', id: 2, show: true, fixed: 'left', sortable: false }, // custom
+ {
+ minWidth: 110,
+ width: false,
+ prop: 'partcode',
+ label: '浜у搧缂栫爜',
+ id: 3,
+ show: true,
+ fixed: false,
+ sortable: true
+ },
+ {
+ minWidth: 110,
+ width: false,
+ prop: 'partname',
+ label: '浜у搧鍚嶇О',
+ id: 4,
+ show: true,
+ fixed: false,
+ sortable: true
+ },
+ {
+ minWidth: 110,
+ width: false,
+ prop: 'partspec',
+ label: '浜у搧瑙勬牸',
+ id: 5,
+ show: true,
+ fixed: false,
+ sortable: true
+ },
+ // {
+ // minWidth: 110,
+ // width: false,
+ // prop: 'wksp_code',
+ // label: '鐢熶骇杞﹂棿缂栫爜',
+ // id: 6,
+ // show: false,
+ // fixed: false,
+ // sortable: true
+ // },
+ // {
+ // minWidth: false,
+ // width: 110,
+ // prop: 'wksp_name',
+ // label: '鐢熶骇杞﹂棿',
+ // id: 7,
+ // show: true,
+ // fixed: false,
+ // sortable: true
+ // },
+ {
+ minWidth: 110,
+ width: false,
+ prop: 'route_code',
+ label: '宸ヨ壓璺嚎缂栫爜',
+ id: 8,
+ show: false,
+ fixed: false,
+ sortable: true
+ }, {
+ minWidth: 110,
+ width: false,
+ prop: 'route_name',
+ label: '宸ヨ壓璺嚎',
+ id: 9,
+ show: true,
+ fixed: false,
+ sortable: true
+ }, {
+ minWidth: 110,
+ width: false,
+ prop: 'stepcode',
+ label: '宸ュ簭缂栫爜',
+ id: 10,
+ show: false,
+ fixed: false,
+ sortable: true
+ }, {
+ minWidth: 110,
+ width: false,
+ prop: 'stepname',
+ label: '宸ュ簭鍚嶇О',
+ id: 11,
+ show: true,
+ fixed: false,
+ sortable: true
+ },
+ {
+ minWidth: 110,
+ width: false,
+ prop: 'unprice',
+ label: '璁′欢鍗曚环',
+ id: 12,
+ show: true,
+ fixed: false,
+ sortable: true
+ },
+ {
+ minWidth: false,
+ width: 110,
+ prop: 'lm_user',
+ label: '鍒涘缓浜哄憳',
+ id: 13,
+ show: true,
+ fixed: false,
+ sortable: true
+ },
+ {
+ minWidth: false,
+ width: 160,
+ prop: 'lm_date',
+ label: '鍒涘缓鏃堕棿',
+ id: 14,
+ show: true,
+ fixed: false,
+ sortable: true
+ }
+
+ ],
+ tableTimeStampArrayKey: new Date().getTime(), // 琛ㄦ牸key
+ dialogVisible: false,
+ dialogForm: {
+ partcode: '', // 浜у搧缂栫爜
+ routecode: '', // 宸ヨ壓璺嚎缂栫爜
+ stepcode: '', // 宸ュ簭缂栫爜
+
+ wkshopcode: '', // 鐢熶骇杞﹂棿缂栫爜
+ eqp_value: '', // 璁惧鑺傛媿
+ stand_value: '', // 鐢熶骇鑺傛媿
+ cavity_qty: '', // 鍨嬭厰鏁�
+ unprice: ''// 璁′欢鍗曚环
+ },
+ routeDialogArr: [], // 宸ヨ壓璺嚎
+ stepDialogArr: [], // 宸ュ簭闆嗗悎
+
+ editPartName: '', // 缂栬緫鏃朵骇鍝佸悕绉�
+ editRouteName: '', // 缂栬緫鏃跺伐鑹鸿矾绾垮悕绉�
+ editStepName: '', // 缂栬緫鏃跺姞宸ュ伐搴忓悕绉�
+ operation: ''
+
+ }
+ },
+
+ activated() {
+ window.addEventListener('resize', this.getHeight)
+ this.getHeight()
+ },
+ created() {
+ this.handleRequest()
+ },
+ mounted() {
+ window.addEventListener('resize', this.getHeight)
+ this.getHeight()
+
+ if (!this.mesSetting.route) {
+ this.tableColumnSettingsArray = this.tableColumnSettingsArray.filter(i => i.prop !== 'route_name')
+ }
+ },
+ methods: {
+ tableColumnUpdate(val, isCopyTrue) {
+ if (isCopyTrue) {
+ this.tableColumnSettingsArray = val
+ }
+ this.tableTimeStampArrayKey = new Date().getTime()
+ this.$refs.tableDataRef.doLayout()
+ },
+ tableRowClassName({ row, rowIndex }) {
+ return 'custom-row'
+ },
+ handleRequest() {
+ this.getBeatRateSearch().then(res => {
+ if (res.code === '200') {
+ this.getPartSelect()
+ }
+ })
+ },
+
+ async getBeatRateSearch() {
+ const res = await BeatRateSearch(this.form)
+ this.tableData = res.data
+ this.total = res.count
+ return { code: res.code }
+ },
+ // 鎺掑簭鏀瑰彉鏃�
+ sortChange({ column, prop, order }) {
+ if (order === 'descending') {
+ order = 'desc'
+ } else if (order === 'ascending') {
+ order = 'asc'
+ } else {
+ order = 'desc'
+ }
+ this.form.order = order
+ this.form.prop = prop
+ this.getBeatRateSearch()
+ },
+ // 鏌ヨ
+ search() {
+ this.getBeatRateSearch()
+ },
+ async getPartSelect() {
+ const { data: res } = await PartSelect()
+ this.partArr = res
+ },
+ async getPartSelect2() {
+ const { data: res } = await PartSelect()
+ this.partArr2 = res
+ },
+ async partChange(val) {
+ const { data: res } = await PartSelectRpute({ partcode: val })
+ if (this.mesSetting.route) {
+ this.routeArr = res
+ this.form.routecode = ''
+ } else {
+ this.stepArr = res
+ }
+ this.form.stepcode = ''
+ },
+ async routeChange(val) {
+ const { data: res } = await RouteSelectStep({ partcode: this.form.partcode, routecode: val })
+ this.stepArr = res
+ this.form.stepcode = ''
+ },
+
+ // 閲嶇疆
+ reset() {
+ this.form.partcode = ''
+ this.form.routecode = ''
+ this.form.stepcode = ''
+ this.getBeatRateSearch()
+ },
+ async partDialogChange(val) {
+ const { data: res } = await PartSelectRpute({ partcode: val })
+ if (this.mesSetting.route) {
+ this.routeDialogArr = res
+ res.forEach(i => {
+ i.unprice = parseFloat(i.unprice) === 0 ? '' : i.unprice
+ })
+ this.stepDialogArr = res
+ this.stepDialogArr = []
+ this.dialogForm.routecode = ''
+ } else {
+ this.stepDialogArr = res
+ res.forEach(i => {
+ i.unprice = parseFloat(i.unprice) === 0 ? '' : i.unprice
+ })
+ this.stepDialogArr = res
+ }
+ },
+ async routeDialogChange(val) {
+ const { data: res } = await RouteSelectStep({ partcode: this.dialogForm.partcode, routecode: val })
+ res.forEach(i => {
+ i.unprice = parseFloat(i.unprice) === 0 ? '' : i.unprice
+ })
+ this.stepDialogArr = res
+ },
+
+ // 鏂板鎸夐挳
+ add(operation) {
+ this.operation = operation
+ this.dialogVisible = true
+ this.getPartSelect2()
+ },
+ // 淇敼鎸夐挳
+ async edit(operation, row) {
+ this.operation = operation
+ this.dialogVisible = true
+
+ this.editPartName = row.partname
+ this.editRouteName = row.route_name
+ this.editStepName = row.stepname
+
+ await this.partDialogChange(row.partcode)
+
+ this.dialogForm.partcode = row.partcode
+ if (this.mesSetting.route) {
+ await this.routeDialogChange(row.route_code)
+ }
+ this.dialogForm.routecode = row.route_code
+ this.dialogForm.stepcode = row.stepcode
+ },
+ // 鍒犻櫎鎸夐挳
+ async del(row) {
+ this.$confirm('鏄惁纭鍒犻櫎?', '鎻愮ず', {
+ confirmButtonText: '纭畾',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning'
+ }).then(() => {
+ DeleteBeatRate({ id: row.id }).then(res => {
+ if (res.code === '200') {
+ this.$message.success('鍒犻櫎鎴愬姛!')
+ if (this.form.page > 1 && this.tableData.length === 1) {
+ this.form.page--
+ }
+ this.getBeatRateSearch()
+ }
+ })
+ }).catch(() => {
+ this.$message.info('宸插彇娑堝垹闄�')
+ })
+ },
+ // 瀵硅瘽妗嗗叧闂簨浠�
+ handleClose() {
+ this.dialogForm.partcode = ''
+ this.dialogForm.routecode = ''
+ this.dialogForm.stepcode = ''
+
+ this.dialogForm.wkshopcode = ''
+ this.dialogForm.eqp_value = ''
+ this.dialogForm.stand_value = ''
+ this.dialogForm.cavity_qty = ''
+ this.dialogForm.unprice = ''
+ this.eqpTableLength = 0
+ this.routeDialogArr = []
+ this.stepDialogArr = []
+
+ this.$refs.dialogForm.clearValidate()
+ this.getBeatRateSearch()
+ },
+ // 瀵硅瘽妗嗗彇娑�
+ dialogVisibleCancel() {
+ this.dialogVisible = false
+ },
+ // 瀵硅瘽妗嗙‘璁�
+ dialogVisibleConfirm() {
+ this.$refs.dialogForm.validate(valid => {
+ if (valid) {
+ const children = []
+ this.stepDialogArr.forEach(i => {
+ children.push({
+ 'code': i.step_code,
+ 'name': i.step_name,
+ 'seq': i.step_seq,
+ 'isbott': i.isbott,
+ 'isend': i.isend,
+ 'unprice': i.unprice.toString().trim() === '' ? 0 : i.unprice
+ })
+ })
+
+ const data = [
+ {
+ 'partcode': this.dialogForm.partcode,
+ 'defaultroute_code': this.dialogForm.routecode,
+ 'children': children
+ }
+ ]
+ SaveBeatRate(data).then(res => {
+ if (res.code === '200') {
+ this.$message.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '淇敼鎴愬姛锛�')
+ this.dialogVisible = false
+ this.getBeatRateSearch()
+ } else {
+ this.$message.error(this.operation === 'add' ? '娣诲姞澶辫触锛�' : '淇敼澶辫触锛�')
+ }
+ })
+ }
+ })
+ },
+
+ // 鑾峰彇椤甸潰楂樺害
+ getHeight() {
+ this.$nextTick(() => {
+ this.mainHeight = window.innerHeight - 85
+ this.tableHeight = this.mainHeight - 195
+ if (window.innerHeight < 769) {
+ this.tableHeight = this.tableHeight - 40
+ }
+ this.$refs.tableDataRef.doLayout()
+ })
+ }
+ }
+}
+</script>
+
+<style>
+.el-table .custom-row {
+ background: #f8f8fa;
+}
+</style>
--
Gitblit v1.9.3