From db457552ab2251fdaaedb8f736e6103f69eccb10 Mon Sep 17 00:00:00 2001 From: zenglf <18502938215@163.com> Date: 星期三, 25 十月 2023 18:44:15 +0800 Subject: [PATCH] 维修工单修改 --- src/views/eam/modules/repairorder/moudles/RepairOrderActualHoursReport.vue | 327 ++++++++++++++++----- src/views/eam/RepairOrderActualWorkHoursList.vue | 240 +++++++++------- src/views/eam/modules/repairorder/moudles/ActualWorkHoursEditTable.vue | 324 ++++++++++---------- 3 files changed, 546 insertions(+), 345 deletions(-) diff --git a/src/views/eam/RepairOrderActualWorkHoursList.vue b/src/views/eam/RepairOrderActualWorkHoursList.vue index 05ec3aa..d51329b 100644 --- a/src/views/eam/RepairOrderActualWorkHoursList.vue +++ b/src/views/eam/RepairOrderActualWorkHoursList.vue @@ -1,16 +1,16 @@ <template> - <a-card :bordered="false" :class="'cust-erp-sub-tab'"> + <a-card :bordered='false' :class="'cust-erp-sub-tab'"> <!-- 鏌ヨ鍖哄煙 --> - <div class="table-page-search-wrapper"> - <a-form layout="inline" @keyup.enter.native="searchQuery"> - <a-row :gutter="24"> + <div class='table-page-search-wrapper'> + <a-form layout='inline' @keyup.enter.native='searchQuery'> + <a-row :gutter='24'> </a-row> </a-form> </div> <!-- 鏌ヨ鍖哄煙-END --> <!-- 鎿嶄綔鎸夐挳鍖哄煙 --> - <div class="table-operator" v-if="mainId"> + <div class='table-operator' v-if='mainId'> <!-- <a-button @click="handleAdd" type="primary" icon="plus">鏂板</a-button> <a-button type="primary" icon="download" @click="handleExportXls('瀹為檯宸ユ椂')">瀵煎嚭</a-button> --> <!-- <a-upload @@ -22,11 +22,16 @@ @change="handleImportExcel"> <a-button type="primary" icon="import">瀵煎叆</a-button> </a-upload> --> - <a-dropdown v-if="selectedRowKeys.length > 0"> - <a-menu slot="overlay"> - <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>鍒犻櫎</a-menu-item> + <a-dropdown v-if='selectedRowKeys.length > 0'> + <a-menu slot='overlay'> + <a-menu-item key='1' @click='batchDel'> + <a-icon type='delete' /> + 鍒犻櫎 + </a-menu-item> </a-menu> - <a-button style="margin-left: 8px"> 鎵归噺鎿嶄綔 <a-icon type="down" /></a-button> + <a-button style='margin-left: 8px'> 鎵归噺鎿嶄綔 + <a-icon type='down' /> + </a-button> </a-dropdown> </div> @@ -38,42 +43,43 @@ </div> --> <a-table - ref="table" - size="middle" + ref='table' + size='middle' bordered - rowKey="id" - :scroll="{x:true}" - :columns="columns" - :dataSource="dataSource" - :pagination="ipagination" - :loading="loading" - @change="handleTableChange"> + rowKey='id' + :scroll='{x:true}' + :columns='columns' + :dataSource='dataSource' + :pagination='ipagination' + :loading='loading' + @change='handleTableChange'> <!-- :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" --> - <template slot="htmlSlot" slot-scope="text"> - <div v-html="text"></div> + <template slot='htmlSlot' slot-scope='text'> + <div v-html='text'></div> </template> - <template slot="imgSlot" slot-scope="text,record"> - <span v-if="!text" style="font-size: 12px;font-style: italic;">鏃犲浘鐗�</span> - <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/> + <template slot='imgSlot' slot-scope='text,record'> + <span v-if='!text' style='font-size: 12px;font-style: italic;'>鏃犲浘鐗�</span> + <img v-else :src='getImgView(text)' :preview='record.id' height='25px' alt='' + style='max-width:80px;font-size: 12px;font-style: italic;' /> </template> - <template slot="fileSlot" slot-scope="text"> - <span v-if="!text" style="font-size: 12px;font-style: italic;">鏃犳枃浠�</span> + <template slot='fileSlot' slot-scope='text'> + <span v-if='!text' style='font-size: 12px;font-style: italic;'>鏃犳枃浠�</span> <a-button v-else - :ghost="true" - type="primary" - icon="download" - size="small" - @click="downloadFile(text)"> + :ghost='true' + type='primary' + icon='download' + size='small' + @click='downloadFile(text)'> 涓嬭浇 </a-button> </template> - <span slot="action" slot-scope="text, record"> - <a @click="handleEdit(record)">缂栬緫</a> - <a-divider type="vertical" /> - <a-popconfirm title="纭畾鍒犻櫎鍚�?" @confirm="() => handleDelete(record.id)"> + <span slot='action' slot-scope='text, record'> + <a @click='handleEdit(record)'>缂栬緫</a> + <a-divider type='vertical' /> + <a-popconfirm title='纭畾鍒犻櫎鍚�?' @confirm='() => handleDelete(record.id)'> <a>鍒犻櫎</a> </a-popconfirm> </span> @@ -81,65 +87,73 @@ </a-table> </div> - <repairOrderActualWorkHours-modal ref="modalForm" @ok="modalFormOk" :mainId="mainId"></repairOrderActualWorkHours-modal> + <repairOrderActualWorkHours-modal ref='modalForm' @ok='modalFormOk' + :mainId='mainId'></repairOrderActualWorkHours-modal> </a-card> </template> <script> - import { JeecgListMixin } from '@/mixins/JeecgListMixin' - import RepairOrderActualWorkHoursModal from './modules/repairorder/RepairOrderActualWorkHoursModal' +import { JeecgListMixin } from '@/mixins/JeecgListMixin' +import RepairOrderActualWorkHoursModal from './modules/repairorder/RepairOrderActualWorkHoursModal' - export default { - name: "RepairOrderActualWorkHoursList", - mixins:[JeecgListMixin], - components: { RepairOrderActualWorkHoursModal }, - props:{ - mainId:{ - type:String, - default:'', - required:false - } - }, - watch:{ - mainId:{ - immediate: true, - handler(val) { - if(!this.mainId){ - this.clearList() - }else{ - this.queryParam['repairOrderId'] = val - this.loadData(1); - } +export default { + name: 'RepairOrderActualWorkHoursList', + mixins: [JeecgListMixin], + components: { RepairOrderActualWorkHoursModal }, + props: { + mainId: { + type: String, + default: '', + required: false + } + }, + watch: { + mainId: { + immediate: true, + handler(val) { + if (!this.mainId) { + this.clearList() + } else { + this.queryParam['repairOrderId'] = val + this.loadData(1) } } - }, - data () { - return { - description: '缁翠慨宸ュ崟绠$悊椤甸潰', - disableMixinCreated:true, - // 琛ㄥご - columns: [ - { - title: '#', - dataIndex: '', - key:'rowIndex', - width:60, - align:"center", - customRender:function (t,r,index) { - return parseInt(index)+1; - } - }, - { + } + }, + data() { + return { + description: '缁翠慨宸ュ崟绠$悊椤甸潰', + disableMixinCreated: true, + // 琛ㄥご + columns: [ + { + title: '#', + dataIndex: '', + key: 'rowIndex', + width: 60, + align: 'center', + customRender: function(t, r, index) { + return parseInt(index) + 1 + } + }, + { title: '浜哄憳缂栫爜', dataIndex: 'username', - align: 'center', + align: 'center' }, { title: '浜哄憳鍚嶇О', dataIndex: 'realname', - align: 'center', + align: 'center' + + }, + + { + title: '涓绘壙淇汉', + dataIndex: 'principalContractor_dictText', + align: 'center' }, // { @@ -151,37 +165,53 @@ { title: '瀹為檯宸ユ椂', dataIndex: 'actualHour', - align: 'center', + align: 'center' }, - ], - url: { - list: "/eam/repairOrder/listRepairOrderActualWorkHoursByMainId", - delete: "/eam/repairOrder/deleteRepairOrderActualWorkHours", - deleteBatch: "/eam/repairOrder/deleteBatchRepairOrderActualWorkHours", - exportXlsUrl: "/eam/repairOrder/exportRepairOrderActualWorkHours", - importUrl: "/eam/repairOrder/importRepairOrderActualWorkHours", - }, - dictOptions:{ - } - } - }, - created() { - }, - computed: { - importExcelUrl(){ - return `${window._CONFIG['domianURL']}/${this.url.importUrl}/${this.mainId}`; - } - }, - methods: { - clearList(){ - this.dataSource=[] - this.selectedRowKeys=[] - this.ipagination.current = 1 - } + { + title: '寮�濮嬫椂闂�', + dataIndex: 'startTime', + align: 'center' + }, + { + title: '缁撴潫鏃堕棿', + dataIndex: 'endTime', + align: 'center' + }, + + { + title: '鐞嗚宸ユ椂', + dataIndex: 'theoreticalTime', + align: 'center' + } + ], + url: { + list: '/eam/repairOrder/listRepairOrderActualWorkHoursByMainId', + delete: '/eam/repairOrder/deleteRepairOrderActualWorkHours', + deleteBatch: '/eam/repairOrder/deleteBatchRepairOrderActualWorkHours', + exportXlsUrl: '/eam/repairOrder/exportRepairOrderActualWorkHours', + importUrl: '/eam/repairOrder/importRepairOrderActualWorkHours' + }, + dictOptions: {} } + }, + created() { + }, + computed: { + importExcelUrl() { + return `${window._CONFIG['domianURL']}/${this.url.importUrl}/${this.mainId}` + } + }, + methods: { + clearList() { + this.dataSource = [] + this.selectedRowKeys = [] + this.ipagination.current = 1 + } + } +} </script> <style scoped> - @import '~@assets/less/common.less' +@import '~@assets/less/common.less' </style> diff --git a/src/views/eam/modules/repairorder/moudles/ActualWorkHoursEditTable.vue b/src/views/eam/modules/repairorder/moudles/ActualWorkHoursEditTable.vue index 8fe8162..a79afa3 100644 --- a/src/views/eam/modules/repairorder/moudles/ActualWorkHoursEditTable.vue +++ b/src/views/eam/modules/repairorder/moudles/ActualWorkHoursEditTable.vue @@ -1,80 +1,82 @@ <template> - <a-card :bordered="false" :class="'cust-erp-sub-tab'"> - <a-table - ref="table" - bordered - rowKey="id" - :columns="columns" - :dataSource="dataSource" - :pagination="ipagination" - @change="handleTableChange" - > - <template - v-for="col in columns" - :slot="col.dataIndex" - slot-scope='text, record, index' - > - <div :key="col.dataIndex"> - <a-input-search - v-if="col.dataIndex == 'username'" - enter-button - @search="onSearchUser(index)" - :value="text" - :read-only="true" - @change="(e) => handleChange(e, record.key, col, index)" - /> - <a-input-number - :value="text" - v-if="col.dataIndex == 'actualHour'" - :min="1" - :max="99999" - @change="(e)=>handleChange(e, record.key, col, index)" - :disabled="record.disabled" - /> - - </div> - </template> - <span slot='action' slot-scope='text, record,index'> - <a @click="handleDeleteFake(index)">鍒犻櫎</a> + <a-card :bordered='false' :class="'cust-erp-sub-tab'"> + <a-table + ref='table' + bordered + rowKey='id' + :columns='columns' + :dataSource='dataSource' + :pagination='ipagination' + @change='handleTableChange' + > + <template + v-for='col in columns' + :slot='col.dataIndex' + slot-scope='text, record, index' + > + <div :key='col.dataIndex'> + <a-input-search + v-if="col.dataIndex == 'username'" + enter-button + @search='onSearchUser(index)' + :value='text' + :read-only='true' + @change='(e) => handleChange(e, record.key, col, index)' + /> + <a-input-number + :value='text' + v-if="col.dataIndex == 'actualHour'" + :min='1' + :max='99999' + @change='(e)=>handleChange(e, record.key, col, index)' + :disabled='record.disabled' + /> + + </div> + </template> + <span slot='action' slot-scope='text, record,index'> + <a @click='handleDeleteFake(index)'>鍒犻櫎</a> </span> - </a-table> - <a-button - style="width: 100%; margin-top: 16px; margin-bottom: 8px" - type="dashed" - icon="plus" - @click="addHour" - :disabled="repairOrderStatus!='3'" - >娣诲姞瀹為檯宸ユ椂 - </a-button> - <div :style="{width: '100%',border: '1px solid #e9e9e9',padding: '10px 16px',background: '#fff',}"> - <a-row :style="{textAlign:'right'}"> - <a-button - :style="{marginRight: '8px'}" - @click="handleCancel" - :disabled="repairOrderStatus!='3'" - > - 娓呯┖ - </a-button> - <a-button - @click="handleOk(1)" - type="primary" - :style="{marginRight: '8px'}" - :disabled="repairOrderStatus!='3'" - >鏆傚瓨</a-button> - <a-button - @click="handleOk(0)" - type="primary" + </a-table> + <a-button + style='width: 100%; margin-top: 16px; margin-bottom: 8px' + type='dashed' + icon='plus' + @click='addHour' + :disabled="repairOrderStatus!='3'" + >娣诲姞瀹為檯宸ユ椂 + </a-button> + <div :style="{width: '100%',border: '1px solid #e9e9e9',padding: '10px 16px',background: '#fff',}"> + <a-row :style="{textAlign:'right'}"> + <a-button + :style="{marginRight: '8px'}" + @click='handleCancel' :disabled="repairOrderStatus!='3'" - >淇濆瓨</a-button> - </a-row> - <!-- :disabled="false" --> - </div> - <actual-hour-user-select - ref="actualUserSelect" - @sendUserRecord="sendUserRecord" - > - </actual-hour-user-select> - </a-card> + > + 娓呯┖ + </a-button> + <a-button + @click='handleOk(1)' + type='primary' + :style="{marginRight: '8px'}" + :disabled="repairOrderStatus!='3'" + >鏆傚瓨 + </a-button> + <a-button + @click='handleOk(0)' + type='primary' + :disabled="repairOrderStatus!='3'" + >淇濆瓨 + </a-button> + </a-row> + <!-- :disabled="false" --> + </div> + <actual-hour-user-select + ref='actualUserSelect' + @sendUserRecord='sendUserRecord' + > + </actual-hour-user-select> + </a-card> </template> <script> import { postAction, getAction } from '@/api/manage' @@ -82,30 +84,30 @@ import pick from 'lodash.pick' import JEllipsis from '@/components/jeecg/JEllipsis' import ActualHourUserSelect from './select/ActualHourUserSelect.vue' + export default { - name: 'ActualWorkHoursEditTable', - mixins: [JeecgListMixin], + name: 'ActualWorkHoursEditTable', + mixins: [JeecgListMixin], components: { JEllipsis, ActualHourUserSelect }, - props:{ - repairOrderId:{ - type:String, - required:false, - default:'' + props: { + repairOrderId: { + type: String, + required: false, + default: '' }, - repairOrderStatus:{ - type:String, - required:false, - default:'' + repairOrderStatus: { + type: String, + required: false, + default: '' } }, data() { return { - title: "宸ヨ壓纭", + title: '缁翠慨宸ュ崟-瀹為檯宸ユ椂', flag: false,//涓婚〉闈㈢殑鏍囪浣� 鐢ㄤ簬鍖哄垎鏄惁纭杩囧伐鍗曞伐鑹� 鏉ュ尯鍒唗able椤靛睍绀� 宸ュ崟宸ュ簭 杩樻槸浜у搧宸ュ簭 - visible: false, model: {}, obj: {}, maskClosable: true, @@ -117,7 +119,7 @@ pageSize: 99, pageSizeOptions: ['99', '199'], showTotal: (total, range) => { - return range[0] + "-" + range[1] + " 鍏�" + total + "鏉�" + return range[0] + '-' + range[1] + ' 鍏�' + total + '鏉�' }, showQuickJumper: true, showSizeChanger: true, @@ -126,99 +128,101 @@ validatorRules: { userId: { rules: [ - { required: true, message: '璇烽�夋嫨浜哄憳!' }, + { required: true, message: '璇烽�夋嫨浜哄憳!' } ] }, actual_hour: { rules: [ - { required: false, message: '璇峰~鍐欏伐鏃�!'}, + { required: false, message: '璇峰~鍐欏伐鏃�!' } ] - }, + } }, labelCol: { xs: { span: 24 }, - sm: { span: 7 }, + sm: { span: 7 } }, wrapperCol: { xs: { span: 24 }, - sm: { span: 16 }, + sm: { span: 16 } }, - drawerWidth: "100%", + drawerWidth: '100%', visible: false, disableSubmit: false, disableSelect: false, loading: false, dataSource: [], columns: [ - { - title: '*浜哄憳缂栫爜', - dataIndex: 'username', - align: "center", - scopedSlots: { customRender: 'username' }, - className: 'red', - width: 250, - }, - { - title: '浜哄憳鍚嶇О', - dataIndex: 'realname', - align: "center", - width: 250, - }, - { - title: '*瀹為檯宸ユ椂', - dataIndex: 'actualHour', - align: "center", - className: 'red', - scopedSlots: { customRender: 'actualHour' }, - width: 250, - }, - { + { + title: '*浜哄憳缂栫爜', + dataIndex: 'username', + align: 'center', + scopedSlots: { customRender: 'username' }, + className: 'red', + width: 250 + }, + { + title: '浜哄憳鍚嶇О', + dataIndex: 'realname', + align: 'center', + width: 250 + }, + + { + title: '*瀹為檯宸ユ椂', + dataIndex: 'actualHour', + align: 'center', + className: 'red', + scopedSlots: { customRender: 'actualHour' }, + width: 250 + }, + + { title: '鎿嶄綔', dataIndex: 'action', align: 'center', width: 250, scopedSlots: { customRender: 'action' } - } - ], + } + ], url: { - list: "/eam/repairOrder/listRepairOrderActualWorkHoursByMainId", - confirmHour:"/eam/repairOrder/addRepairOrderActualWorkHours" + list: '/eam/repairOrder/listRepairOrderActualWorkHoursByMainId', + confirmHour: '/eam/repairOrder/addRepairOrderActualWorkHours' }, changeIndex: 0 } }, - created(){ - this.queryParam['repairOrderId'] = this.repairOrderId; - this.loadData(1); + created() { + this.queryParam['repairOrderId'] = this.repairOrderId + this.loadData(1) }, methods: { addHour() { - this.dataSource.push({userId:'',repairOrderId:this.repairOrderId,actualHour:0,username:'',realname:''}) + this.dataSource.push({ userId: '', repairOrderId: this.repairOrderId, actualHour: 0, username: '', realname: '' }) }, handleCancel() { this.close() }, close() { - this.$emit('close'); + this.$emit('close') this.dataSource = [] - this.disableSubmit = false; - this.visible = false; + this.disableSubmit = false + this.visible = false }, - handleDeleteFake(index){ - this.dataSource.pop(index); + handleDeleteFake(index) { + this.dataSource.pop(index) }, handleOk(saveStatus) { const that = this - if(saveStatus==0){ - let workHoursDataSource = that.dataSource; + if (saveStatus == 0) { + let workHoursDataSource = that.dataSource for (let i = 0; i < workHoursDataSource.length; i++) { if (workHoursDataSource[i].userId == undefined || workHoursDataSource[i].userId == null || workHoursDataSource[i].userId == '') { - that.$message.warning("璇烽�夋嫨绗�"+(i+1)+"琛岀淮淇汉鍛橈紒"); - return false; + that.$message.warning('璇烽�夋嫨绗�' + (i + 1) + '琛岀淮淇汉鍛橈紒') + return false } - if(workHoursDataSource[i].actualHour == undefined || workHoursDataSource[i].actualHour == null||workHoursDataSource[i].actualHour==''){ - that.$message.warning("璇峰~鍐欑"+(i+1)+"琛屽疄闄呭伐鏃讹紒"); - return false; + if (workHoursDataSource[i].actualHour == undefined || workHoursDataSource[i].actualHour == null || workHoursDataSource[i].actualHour == '') { + that.$message.warning('璇峰~鍐欑' + (i + 1) + '琛屽疄闄呭伐鏃讹紒') + return false } } } @@ -226,8 +230,8 @@ if (!err) { that.confirmLoading = true let formData = {} - formData.repairOrderId = that.repairOrderId; - formData.actualHourList = that.dataSource; + formData.repairOrderId = that.repairOrderId + formData.actualHourList = that.dataSource let obj = obj = postAction(this.url.confirmHour, formData) obj.then((res) => { if (res.success) { @@ -239,24 +243,24 @@ }).finally(() => { that.confirmLoading = false that.close() - that.loadData(1); + that.loadData(1) }) } }) }, handleChange(value, key, column, index) { - let that = this; - const temp = [...that.dataSource]; - const target = temp[index]; + let that = this + const temp = [...that.dataSource] + const target = temp[index] if (target) { - target[column.dataIndex] = value; + target[column.dataIndex] = value if ('userId' == column.dataIndex) { - target['userId'] = value; + target['userId'] = value } if ('actualHour' == column.dataIndex) { - target['actualHour'] = value; + target['actualHour'] = value } - that.dataSource = temp; + that.dataSource = temp } }, onSearchUser(index) { @@ -270,25 +274,25 @@ const target = temp[this.recordIndex] if (target) { console.log(record) - target.userId = record.id; - target.username = record.username; - target.realname = record.realname; + target.userId = record.id + target.username = record.username + target.realname = record.realname this.dataSource = temp } }, - clearList(){ - this.dataSource=[]; - this.ipagination.current = 1 + clearList() { + this.dataSource = [] + this.ipagination.current = 1 } }, - watch:{ - repairOrderId:{ + watch: { + repairOrderId: { immediate: true, - handler(val) { - this.clearList(); - this.queryParam['repairOrderId'] = val - this.loadData(1); - } + handler(val) { + this.clearList() + this.queryParam['repairOrderId'] = val + this.loadData(1) + } } } } diff --git a/src/views/eam/modules/repairorder/moudles/RepairOrderActualHoursReport.vue b/src/views/eam/modules/repairorder/moudles/RepairOrderActualHoursReport.vue index 7d45d2a..3a61ac0 100644 --- a/src/views/eam/modules/repairorder/moudles/RepairOrderActualHoursReport.vue +++ b/src/views/eam/modules/repairorder/moudles/RepairOrderActualHoursReport.vue @@ -1,41 +1,87 @@ <template> <a-card - :bordered="false" + :bordered='false' :class="'cust-erp-sub-tab'" > <a-table - ref="table" + ref='table' bordered - rowKey="id" - :columns="columns" - :dataSource="dataSource" - :pagination="ipagination" - @change="handleTableChange" + rowKey='id' + :columns='columns' + :dataSource='dataSource' + :pagination='ipagination' + @change='handleTableChange' > <template - v-for="col in columns" - :slot="col.dataIndex" + v-for='col in columns' + :slot='col.dataIndex' slot-scope='text, record, index' > - <div :key="col.dataIndex"> + <div :key='col.dataIndex'> <a-input-search v-if="col.dataIndex == 'username'" enter-button - @search="onSearchUser(index)" - :value="text" - :read-only="true" - @change="(e) => handleChange(e, record.key, col, index)" + @search='onSearchUser(index)' + :value='text' + :read-only='true' + @change='(e) => handleChange(e, record.key, col, index)' :disabled="repairOrderStatus=='4'" /> <a-input-number - :value="text" + :value='text' v-if="col.dataIndex == 'actualHour'" - :min="0" - :max="99999" - @change="(e)=>handleChange(e, record.key, col, index)" + :min='0' + :max='99999' + @change='(e)=>handleChange(e, record.key, col, index)' :disabled="repairOrderStatus=='4'" /> + <!-- <a-switch @change='(e)=>onChange(e, record.key, col, index)' :value='text' :disabled="repairOrderStatus=='4'"--> + <!-- v-if="col.dataIndex == 'principalContractor'" />--> + <a-select default-value='0' :value='text' :disabled="repairOrderStatus=='4'" + v-if="col.dataIndex == 'principalContractor'" + @change='(e)=>handleChange(e, record.key, col, index)'> + <a-select-opt-group> + <a-select-option value='1'> + 鏄� + </a-select-option> + <a-select-option value='0'> + 鍚� + </a-select-option> + </a-select-opt-group> + + </a-select> + <!-- <a-range-picker--> + <!-- :ranges="{ Today: [moment(), moment()], 'This Month': [moment(), moment().endOf('month')] }"--> + <!-- :show-time="{ format: 'HH:mm' }"--> + <!-- format="YYYY-MM-DD HH:mm"--> + <!-- :placeholder="['Start Time', 'End Time']"--> + <!-- v-if="col.dataIndex == 'startTime'" @change='onDateChange'--> + <!-- />--> + <a-date-picker + :disabled="repairOrderStatus=='4'" + :value='text' + format='YYYY-MM-DD HH:mm' + :show-time="{ defaultValue: moment('00:00', 'HH:mm') }" + v-if="col.dataIndex == 'startTime'" @change='(e)=>handleChange(e, record.key, col, index)' + /> + <!-- :disabled="repairOrderStatus=='4'"--> + <a-date-picker + :value='text' + format='YYYY-MM-DD HH:mm' + :show-time="{ defaultValue: moment('00:00', 'HH:mm') }" + v-if="col.dataIndex == 'endTime'" @change='(e)=>handleChange(e, record.key, col, index)' + /> + + <!-- <a-input-number--> + <!-- :value='text'--> + <!-- v-if="col.dataIndex == 'theoreticalTime'"--> + <!-- :min='0'--> + <!-- :max='99999'--> + <!-- :read-only='true'--> + <!-- @change='(e)=>handleChange(e, record.key, col, index)'--> + <!-- :disabled="true"--> + <!-- />--> </div> </template> <span @@ -44,15 +90,15 @@ > <a :disabled="repairOrderStatus=='4'" - @click="handleDelete(index)" + @click='handleDelete(index)' >鍒犻櫎</a> </span> </a-table> <a-button - style="width: 100%; margin-top: 16px; margin-bottom: 8px" - type="dashed" - icon="plus" - @click="addHour" + style='width: 100%; margin-top: 16px; margin-bottom: 8px' + type='dashed' + icon='plus' + @click='addHour' :disabled="this.repairOrderStatus=='4' || this.repairOrderStatus=='2'" >娣诲姞瀹為檯宸ユ椂 <!-- :disabled="mainId.status=='4'" --> @@ -61,27 +107,29 @@ <a-row :style="{textAlign:'right'}"> <a-button :style="{marginRight: '8px'}" - @click="handleCancel" + @click='handleCancel' > 鍙栨秷 </a-button> <a-button - @click="handleOk(1)" - type="primary" + @click='handleOk(1)' + type='primary' :style="{marginRight: '8px'}" :disabled="this.repairOrderStatus=='4' || this.repairOrderStatus=='2'" - >鏆傚瓨</a-button> + >鏆傚瓨 + </a-button> <a-button - @click="handleOk(0)" - type="primary" + @click='handleOk(0)' + type='primary' :disabled="this.repairOrderStatus=='4' || this.repairOrderStatus=='2'" - >淇濆瓨</a-button> + >淇濆瓨 + </a-button> </a-row> <!-- :disabled="false" --> </div> <actual-hour-user-select - ref="actualUserSelect" - @sendUserRecord="sendUserRecord" + ref='actualUserSelect' + @sendUserRecord='sendUserRecord' > </actual-hour-user-select> </a-card> @@ -92,12 +140,15 @@ import pick from 'lodash.pick' import JEllipsis from '@/components/jeecg/JEllipsis' import ActualHourUserSelect from './select/ActualHourUserSelect.vue' +import moment from 'moment' + export default { name: 'RepairOrderActualWorkHoursList', mixins: [JeecgListMixin], components: { JEllipsis, ActualHourUserSelect + }, // props: { // mainId: { @@ -121,13 +172,12 @@ type: String, required: false, default: '' - }, + } }, data() { return { - title: "瀹為檯宸ユ椂", + title: '瀹為檯宸ユ椂', flag: false,//涓婚〉闈㈢殑鏍囪浣� 鐢ㄤ簬鍖哄垎鏄惁纭杩囧伐鍗曞伐鑹� 鏉ュ尯鍒唗able椤靛睍绀� 宸ュ崟宸ュ簭 杩樻槸浜у搧宸ュ簭 - visible: false, model: {}, obj: {}, maskClosable: true, @@ -139,7 +189,7 @@ pageSize: 99, pageSizeOptions: ['99', '199'], showTotal: (total, range) => { - return range[0] + "-" + range[1] + " 鍏�" + total + "鏉�" + return range[0] + '-' + range[1] + ' 鍏�' + total + '鏉�' }, showQuickJumper: true, showSizeChanger: true, @@ -148,24 +198,24 @@ validatorRules: { userId: { rules: [ - { required: true, message: '璇烽�夋嫨浜哄憳!' }, + { required: true, message: '璇烽�夋嫨浜哄憳!' } ] }, actual_hour: { rules: [ - { required: false, message: '璇峰~鍐欏伐鏃�!' }, + { required: false, message: '璇峰~鍐欏伐鏃�!' } ] - }, + } }, labelCol: { xs: { span: 24 }, - sm: { span: 7 }, + sm: { span: 7 } }, wrapperCol: { xs: { span: 24 }, - sm: { span: 16 }, + sm: { span: 16 } }, - drawerWidth: "100%", + drawerWidth: '100%', visible: false, disableSubmit: false, disableSelect: false, @@ -177,32 +227,58 @@ dataIndex: '', key: 'rowIndex', width: 60, - align: "center", - customRender: function (t, r, index) { - return parseInt(index) + 1; + align: 'center', + customRender: function(t, r, index) { + return parseInt(index) + 1 } }, { title: '*浜哄憳缂栫爜', dataIndex: 'username', - align: "center", + align: 'center', scopedSlots: { customRender: 'username' }, className: 'red', - width: 250, + width: 250 }, { title: '浜哄憳鍚嶇О', dataIndex: 'realname', - align: "center", - width: 250, + align: 'center', + width: 150 + }, + { + title: '涓绘壙淇汉', + dataIndex: 'principalContractor', + align: 'center', + scopedSlots: { customRender: 'principalContractor' }, + width: 100 }, { title: '*瀹為檯宸ユ椂', dataIndex: 'actualHour', - align: "center", + align: 'center', className: 'red', scopedSlots: { customRender: 'actualHour' }, - width: 250, + width: 120 + }, + { + title: '寮�濮嬫椂闂�', + dataIndex: 'startTime', + scopedSlots: { customRender: 'startTime' }, + align: 'center' + }, + { + title: '缁撴潫鏃堕棿', + dataIndex: 'endTime', + align: 'center', + scopedSlots: { customRender: 'endTime' } + }, + + { + title: '鐞嗚宸ユ椂', + dataIndex: 'theoreticalTime', + align: 'center' + // scopedSlots: { customRender: 'theoreticalTime' }, }, { title: '鎿嶄綔', @@ -214,7 +290,7 @@ ], url: { list: '/eam/repairOrder/listRepairOrderActualWorkHoursByMainId', - confirmHour: '/eam/repairOrderActualHours/add', + confirmHour: '/eam/repairOrderActualHours/add' }, changeIndex: 0 } @@ -224,46 +300,59 @@ repairOrderId: { immediate: true, handler(val) { - this.clearList(); + this.clearList() this.queryParam['repairOrderId'] = val this.loadData(1) } - }, + } }, methods: { + moment, + onChange(checked) { + console.log(`a-switch to ${checked}`) + }, +//鏃堕棿閫夋嫨淇敼 + onStartTimeChange() { + console.log() + + }, + onEndTimeChange() { + console.log() + + }, addHour() { this.dataSource.push({ userId: '', repairOrderId: this.repairOrderId, actualHour: 0, username: '', realname: '' }) }, handleCancel() { - this.$bus.$emit('closeDrawer'); + this.$bus.$emit('closeDrawer') }, close() { - this.$emit('close'); + this.$emit('close') this.dataSource = [] - this.disableSubmit = false; - this.visible = false; + this.disableSubmit = false + this.visible = false }, handleDelete(text, record, index) { - this.dataSource.splice(index, 1); + this.dataSource.splice(index, 1) }, handleOk(saveStatus) { const that = this if (saveStatus == 0) { - let workHoursDataSource = that.dataSource; + let workHoursDataSource = that.dataSource for (let i = 0; i < workHoursDataSource.length; i++) { if (workHoursDataSource[i].userId == undefined || workHoursDataSource[i].userId == null || workHoursDataSource[i].userId == '') { - that.$message.warning("璇烽�夋嫨绗�" + (i + 1) + "琛岀淮淇汉鍛橈紒"); - return false; + that.$message.warning('璇烽�夋嫨绗�' + (i + 1) + '琛岀淮淇汉鍛橈紒') + return false } if (workHoursDataSource[i].actualHour == undefined || workHoursDataSource[i].actualHour == null || workHoursDataSource[i].actualHour == '') { - that.$message.warning("璇峰~鍐欑" + (i + 1) + "琛屽疄闄呭伐鏃讹紒"); - return false; + that.$message.warning('璇峰~鍐欑' + (i + 1) + '琛屽疄闄呭伐鏃讹紒') + return false } } } if (that.dataSource.length === 0) { - that.$message.warning("璇烽�夋嫨浜哄憳锛�") + that.$message.warning('璇烽�夋嫨浜哄憳锛�') return } this.form.validateFields((err, values) => { @@ -271,8 +360,14 @@ that.confirmLoading = true let formData = {} // formData.repairOrderId = that.mainId.id; - formData.repairOrderId = that.repairOrderId; - formData.repairOrderActualWorkHoursList = that.dataSource; + formData.repairOrderId = that.repairOrderId + formData.repairOrderActualWorkHoursList = that.dataSource + for (let i = 0; i < formData.repairOrderActualWorkHoursList.length; i++) { + const start = formData.repairOrderActualWorkHoursList[i].startTime + const end = formData.repairOrderActualWorkHoursList[i].endTime + formData.repairOrderActualWorkHoursList[i].startTime = moment(start).format('yyyy-MM-DD HH:mm') + formData.repairOrderActualWorkHoursList[i].endTime = moment(end).format('yyyy-MM-DD HH:mm') + } // formData.equipmentId = that.equipmentId; let obj = obj = postAction(this.url.confirmHour, formData) obj.then((res) => { @@ -285,24 +380,87 @@ }).finally(() => { that.confirmLoading = false that.close() - that.loadData(1); + that.loadData(1) }) } }) }, handleChange(value, key, column, index) { - let that = this; - const temp = [...that.dataSource]; - const target = temp[index]; + let that = this + const temp = [...that.dataSource] + const target = temp[index] if (target) { - target[column.dataIndex] = value; + target[column.dataIndex] = value if ('userId' == column.dataIndex) { - target['userId'] = value; + target['userId'] = value } + if ('principalContractor' == column.dataIndex) { + target['principalContractor'] = value + } + if ('actualHour' == column.dataIndex) { - target['actualHour'] = value; + target['actualHour'] = value } - that.dataSource = temp; + // if ('theoreticalTime' == column.dataIndex) { + // target['theoreticalTime'] = value + // } + if ('startTime' == column.dataIndex) { + + if (target['endTime'] == null) { + target['startTime'] = value + } else if (target['startTime'] != null && target['endTime'] != null) { + const diffInHours = this.getTimeDiff(target['startTime'], target['endTime']) + if (diffInHours < 0) { + target['startTime'] = '' + target['theoreticalTime'] = '' + that.$message.error('璇锋鏌ョ' + (index + 1) + '琛屽紑濮嬫椂闂翠笉鑳藉皬浜庣粨鏉熸椂闂�,璇烽噸鏂伴�夋嫨') + } else { + target['startTime'] = value + target['theoreticalTime'] = diffInHours + } + } else if (target['startTime'] == null && target['endTime'] != null) { + const diffInHours = this.getTimeDiff(value, target['endTime']) + if (diffInHours < 0) { + target['startTime'] = '' + target['theoreticalTime'] = '' + that.$message.error('璇锋鏌ョ' + (index + 1) + '琛屽紑濮嬫椂闂翠笉鑳藉皬浜庣粨鏉熸椂闂�,璇烽噸鏂伴�夋嫨') + + } else { + target['startTime'] = value + target['theoreticalTime'] = diffInHours + } + } + + } + + if ('endTime' == column.dataIndex) { + if (target['startTime'] == null) { + target['endTime'] = value + } else if (target['startTime'] != null && target['endTime'] != null) { + const diffInHours = this.getTimeDiff(target['startTime'], target['endTime']) + if (diffInHours < 0) { + target['endTime'] = '' + target['theoreticalTime'] = '' + that.$message.error('璇锋鏌ョ' + (index + 1) + '琛屽紑濮嬫椂闂翠笉鑳藉皬浜庣粨鏉熸椂闂�,璇烽噸鏂伴�夋嫨') + } else { + target['endTime'] = value + target['theoreticalTime'] = diffInHours + } + + } else if (target['startTime'] != null && target['endTime'] == null) { + const diffInHours = this.getTimeDiff(target['startTime'], value) + if (diffInHours < 0) { + target['endTime'] = '' + target['theoreticalTime'] = '' + that.$message.error('璇锋鏌ョ' + (index + 1) + '琛屽紑濮嬫椂闂翠笉鑳藉皬浜庣粨鏉熸椂闂�,璇烽噸鏂伴�夋嫨') + + } else { + target['endTime'] = value + target['theoreticalTime'] = diffInHours + } + } + } + that.dataSource = temp } }, onSearchUser(index) { @@ -317,17 +475,26 @@ const target = temp[this.recordIndex] if (target) { console.log(record) - target.userId = record.id; - target.username = record.username; - target.realname = record.realname; + target.userId = record.id + target.username = record.username + target.realname = record.realname this.dataSource = temp } }, clearList() { - this.dataSource = []; + this.dataSource = [] this.ipagination.current = 1 + }, + // 鑾峰彇寮�濮嬫椂闂村拰缁撴潫鏃堕棿鐨勬椂闂村樊 + getTimeDiff(startTime, endTime) { + const start = moment(startTime, 'YYYY-MM-DD HH:mm:ss') + const end = moment(endTime, 'YYYY-MM-DD HH:mm:ss') + const diff = end.diff(start) + var duration = moment.duration(diff) + var diffInHours = duration.asHours() + return diffInHours.toFixed(1) } - }, + } } </script> -- Gitblit v1.9.3