Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/新增上传模型功能

This commit is contained in:
jinling.yang
2023-08-24 17:32:59 +08:00
6 changed files with 202 additions and 84 deletions

View File

@@ -8,27 +8,34 @@
white-space: nowrap; white-space: nowrap;
} }
div:has(.o_required_modifier)>label::before { div:has(.o_required_modifier) > label::before {
content: '*' !important; content: '*' !important;
color: red !important; color: red !important;
padding: 0 4px !important; padding: 0 4px !important;
vertical-align: top !important; vertical-align: top !important;
font-size: 1.5rem !important; font-size: 1.5rem !important;
}
.my-image div {
width: 100px !important;
height: 130px !important;
} }
.my-image div {
width: 110px !important;
height: 110px !important;
}
.add_flex { .add_flex {
padding: 5px 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-between;
} }
.maintenance_name { .maintenance_name {
font-weight: bold; font-weight: bold;
} }
.o_kanban_renderer .o_kanban_record .o_kanban_record_has_image_fill .o_kanban_image_fill_left { .o_kanban_renderer .o_kanban_record .o_kanban_record_has_image_fill .o_kanban_image_fill_left {
flex:unset !important; flex: unset !important;
} }
.o_kanban_renderer .o_kanban_record .o_kanban_record_bottom { .o_kanban_renderer .o_kanban_record .o_kanban_record_bottom {
margin-top: 5px; margin-top: 5px;
display: inline !important; display: inline !important;
@@ -36,4 +43,80 @@ div:has(.o_required_modifier)>label::before {
td.o_required_modifier { td.o_required_modifier {
display: table-cell !important; display: table-cell !important;
}
.show_state {
display: flex;
flex-direction: column;
position: absolute;
top: 0;
bottom: 0;
right: 8px;
margin: auto;
height: 34px;
}
.show_state > div {
width: 12px;
height: 12px;
border: 1px solid #000
}
.show_state > div:nth-child(2) {
border-top: none;
border-bottom: none;
}
.oe_kanban_card.kanban_color_2 {
background-color: #FF4343 !important;
color: #fff;
}
.oe_kanban_card.kanban_color_1 {
background-color: #27FEA9 !important;
opacity: 0.7;
color: #fff;
}
.oe_kanban_card.kanban_color_3 {
background-color: rgb(255, 150, 0) !important;
color: #fff;
}
.my-image img {
width: 100%;
height: 100%;
}
.color_1 {
background-color: #27FEA9;
}
.color_2 {
background-color: #FF4343;
}
.color_3 {
background-color: rgb(255, 150, 0);
}
.font_color_1 {
color: rgb(0, 183, 0);
}
.font_color_2 {
color: #FF4343;
}
.font_color_3 {
color: rgb(255, 150, 0);
}
.o_kanban_card_header_title {
font-size: 15px;
}
.o_kanban_record_bottom {
font-family: '华文中宋';
//font-weight: bold;
} }

View File

@@ -26,12 +26,12 @@
</header> </header>
</xpath> </xpath>
<xpath expr="//page[@name='maintenance']" position="attributes"> <xpath expr="//page[@name='maintenance']" position="attributes">
<attribute name="string">维保</attribute> <attribute name="string">维保</attribute>
</xpath> </xpath>
<xpath expr="//field[@name='maintenance_count']" position="attributes"> <xpath expr="//field[@name='maintenance_count']" position="attributes">
<attribute name="string">维保</attribute> <attribute name="string">维保</attribute>
</xpath> </xpath>
<!-- <field string="Maintenance" name="maintenance_count" widget="statinfo"/>--> <!-- <field string="Maintenance" name="maintenance_count" widget="statinfo"/>-->
<xpath expr="//div[@name='button_box']" position="inside"> <xpath expr="//div[@name='button_box']" position="inside">
<button name="%(action_maintenance_logs)d" <button name="%(action_maintenance_logs)d"
@@ -284,12 +284,11 @@
<field name="machine_tool_picture"/> <field name="machine_tool_picture"/>
</xpath> </xpath>
<xpath expr="//templates" position="inside">
<xpath expr="//templates" position="inside">
<t t-name="kanban-box"> <t t-name="kanban-box">
<div t-attf-class="oe_kanban_global_click o_kanban_record_has_image_fill o_hr_kanban_record oe_kanban_card oe_kanban_global_click <div t-attf-class="oe_kanban_global_click o_kanban_record_has_image_fill o_hr_kanban_record oe_kanban_card oe_kanban_global_click">
#{record.state.raw_value == '正常' ? 'kanban_color_1' : ''}
#{record.state.raw_value == '故障' ? 'kanban_color_2' : ''}
#{record.state.raw_value == '不可用' ? 'kanban_color_3' : ''}">
<field name="machine_tool_picture" class="o_kanban_image_fill_left d-block my-image" <field name="machine_tool_picture" class="o_kanban_image_fill_left d-block my-image"
preview_image="image_128" widget="image"/> preview_image="image_128" widget="image"/>
@@ -304,7 +303,13 @@
<div class="o_kanban_record_bottom state_zc"> <div class="o_kanban_record_bottom state_zc">
<field name="state_zc"/> <field name="state_zc"/>
</div> </div>
<div class="o_kanban_record_bottom state_zc"> <div class="o_kanban_record_bottom state_zc">
<field name="technician_user_id"/>
</div>
<div class="o_kanban_record_bottom state_zc"
t-attf-class="#{record.state.raw_value == '正常' ? 'font_color_1' : ''}
#{record.state.raw_value == '故障' ? 'font_color_2' : ''}
#{record.state.raw_value == '不可用' ? 'font_color_3' : ''}">
<field name="state"/> <field name="state"/>
</div> </div>
<!-- <div class="o_kanban_record_bottom">--> <!-- <div class="o_kanban_record_bottom">-->
@@ -313,7 +318,12 @@
<!-- <field name="supplier_id"/>--> <!-- <field name="supplier_id"/>-->
<!-- </div>--> <!-- </div>-->
</div> </div>
<div class="show_state" t-attf-class="oe_kanban_global_click o_kanban_record_has_image_fill o_hr_kanban_record oe_kanban_card oe_kanban_global_click
">
<div t-attf-class="#{record.state.raw_value == '正常' ? 'color_1' : ''}"></div>
<div t-attf-class="#{record.state.raw_value == '故障' ? 'color_2' : ''}"></div>
<div t-attf-class="#{record.state.raw_value == '不可用' ? 'color_3' : ''}"></div>
</div>
</div> </div>
</t> </t>
</xpath> </xpath>

View File

@@ -9,7 +9,6 @@ class ResWorkcenter(models.Model):
# 生产线显示 # 生产线显示
production_line_show = fields.Char(string='生产线') production_line_show = fields.Char(string='生产线')
equipment_id = fields.Many2one('maintenance.equipment', string='设备')
machine_tool_id = fields.Many2one('sf.machine_tool', string='机床') machine_tool_id = fields.Many2one('sf.machine_tool', string='机床')
production_line_id = fields.Many2one('sf.production.line', string='生产线') production_line_id = fields.Many2one('sf.production.line', string='生产线')
is_process_outsourcing = fields.Boolean('工艺外协') is_process_outsourcing = fields.Boolean('工艺外协')
@@ -19,6 +18,12 @@ class ResWorkcenter(models.Model):
'maintenance.equipment', string="设备", 'maintenance.equipment', string="设备",
check_company=True) check_company=True)
equipment_status = fields.Selection(
[("正常", "正常"), ("故障", "故障"), ("不可用", "不可用")],
string="设备状态", related='equipment_id.state')
equipment_image = fields.Binary('设备图片', related='equipment_id.machine_tool_picture')
# 查询工艺外协加工中心 # 查询工艺外协加工中心
def get_process_outsourcing_workcenter(self): def get_process_outsourcing_workcenter(self):
outsourcing_workcenter = self.env['mrp.workcenter'].search([('is_process_outsourcing', '=', True)]) outsourcing_workcenter = self.env['mrp.workcenter'].search([('is_process_outsourcing', '=', True)])

View File

@@ -24,19 +24,28 @@
</field> </field>
</record> </record>
<!-- <record id="mrp_workcenter_view_kanban_inherit_workorder" model="ir.ui.view">--> <record id="mrp_workcenter_view_kanban_inherit_workorder" model="ir.ui.view">
<!-- <field name="name">mrp.workcenter.view.kanban.inherit.mrp.workorder</field>--> <field name="name">mrp.workcenter.view.kanban.inherit.mrp.workorder</field>
<!-- <field name="model">mrp.workcenter</field>--> <field name="model">mrp.workcenter</field>
<!-- <field name="inherit_id" ref="mrp.mrp_workcenter_kanban"/>--> <field name="inherit_id" ref="mrp.mrp_workcenter_kanban"/>
<!-- <field name="arch" type="xml">--> <field name="arch" type="xml">
<!-- &lt;!&ndash; Desktop view &ndash;&gt;--> <!-- Desktop view -->
<!-- <xpath expr="//div[@name='o_wo']" position="inside">--> <xpath expr='(//field[@name="name"])[1]' position="after">
<!-- <button class="btn btn-secondary fa fa-desktop" name="action_work_order" type="object"-->
<!-- context="{'search_default_ready': 1, 'search_default_progress': 1, 'search_default_pending': 1, 'desktop_list_view': 1, 'search_default_workcenter_id': active_id}"--> <field name="equipment_status" />
<!-- title="Work orders" aria-label="Work orders"/>--> <field name="equipment_image" />
<!-- </xpath>-->
<!-- </field>-->
<!-- </record>--> </xpath>
<xpath expr='(//field[@name="name"])[2]' position="after">
<field name="equipment_status" />
<field name="equipment_image" widget="image" />
</xpath>
</field>
</record>
<!-- override to change the no content image --> <!-- override to change the no content image -->
<record id="mrp.action_work_orders" model="ir.actions.act_window"> <record id="mrp.action_work_orders" model="ir.actions.act_window">
@@ -90,6 +99,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='company_id']" position="after"> <xpath expr="//field[@name='company_id']" position="after">
<field name="users_ids" widget="many2many_tags" string="可操作用户"/> <field name="users_ids" widget="many2many_tags" string="可操作用户"/>
<field name="equipment_status"/>
</xpath> </xpath>
<xpath expr="//field[@name='alternative_workcenter_ids']" position="after"> <xpath expr="//field[@name='alternative_workcenter_ids']" position="after">
<field name="production_line_id"/> <field name="production_line_id"/>

View File

@@ -1,14 +1,14 @@
/** @odoo-module **/ /** @odoo-module **/
import { registry } from "@web/core/registry"; import {registry} from "@web/core/registry";
import { _lt } from "@web/core/l10n/translation"; import {_lt} from "@web/core/l10n/translation";
import { standardFieldProps } from "@web/views/fields/standard_field_props"; import {standardFieldProps} from "@web/views/fields/standard_field_props";
import { useInputField } from "@web/views/fields/input_field_hook"; import {useInputField} from "@web/views/fields/input_field_hook";
import { FileUploader } from "@web/views/fields/file_handler"; import {FileUploader} from "@web/views/fields/file_handler";
import { session } from "@web/session"; import {session} from "@web/session";
import { useService } from "@web/core/utils/hooks"; import {useService} from "@web/core/utils/hooks";
import { isBinarySize } from "@web/core/utils/binary"; import {isBinarySize} from "@web/core/utils/binary";
import { download } from "@web/core/network/download"; import {download} from "@web/core/network/download";
import utils from 'web.utils'; import utils from 'web.utils';
import core from 'web.core'; import core from 'web.core';
@@ -16,13 +16,14 @@ import rpc from 'web.rpc';
var QWeb = core.qweb; var QWeb = core.qweb;
import { Component, onWillUpdateProps, useState, useRef, useEffect } from "@odoo/owl"; import {Component, onWillUpdateProps, useState, useRef, useEffect} from "@odoo/owl";
export class StepViewer extends Component { export class StepViewer extends Component {
setup() { setup() {
this.props.url = this.formatUrl(); this.props.url = this.formatUrl();
} }
formatUrl(){
formatUrl() {
var url = ''; var url = '';
if (this.props.value) { if (this.props.value) {
if (this.props.value.slice(-1) == 'b' && !isNaN(this.props.value.split(' ')[0])) { if (this.props.value.slice(-1) == 'b' && !isNaN(this.props.value.split(' ')[0])) {
@@ -30,23 +31,27 @@ export class StepViewer extends Component {
base_url: session['web.base.url'], base_url: session['web.base.url'],
model: this.props.record.resModel, model: this.props.record.resModel,
id: JSON.stringify(this.props.record.data['id']), id: JSON.stringify(this.props.record.data['id']),
field: this.props.name} field: this.props.name
url = url_props['base_url'].replace('http://', 'https://') +'/web/content/'+url_props['model']+'/'+url_props['id']+'/'+url_props['field']+'?download=true' }
url = url_props['base_url'].replace('http://', 'https://') + '/web/content/' + url_props['model'] + '/' + url_props['id'] + '/' + url_props['field'] + '?download=true'
// url = 'http://localhost:8069'+'/web/content/'+url_props['model']+'/'+url_props['id']+'/'+url_props['field']+'?download=true' // url = 'http://localhost:8069'+'/web/content/'+url_props['model']+'/'+url_props['id']+'/'+url_props['field']+'?download=true'
console.log('url111111',url) console.log('url111111', url)
return url return url
} else { } else {
url = "data:model/gltf-binary;base64," + this.props.value; url = "data:model/gltf-binary;base64," + this.props.value;
console.log('url2',url) console.log('url2', url)
return url return url
// localStorage.setItem('url',url) // localStorage.setItem('url',url)
// let new_url = localStorage.getItem(('url')) // let new_url = localStorage.getItem(('url'))
// var oViewer = document.getElementsByTagName('model-viewer')[0]; // var oViewer = document.getElementsByTagName('model-viewer')[0];
// return new_url // return new_url
// url = "web_widget_model_viewer/static/src/images/not_model.png"; // url = "web_widget_model_viewer/static/src/images/not_model.png";
} }
} else {
var oImg = document.getElementsByClassName('test')[0]
console.log(oImg)
} }
} }
} }
StepViewer.template = "web_widget_model_viewer.BinaryField3d"; StepViewer.template = "web_widget_model_viewer.BinaryField3d";
@@ -56,10 +61,10 @@ StepViewer.supportedTypes = ["binary"];
StepViewer.props = { StepViewer.props = {
...standardFieldProps, ...standardFieldProps,
url: { type: String, optional: true }, url: {type: String, optional: true},
}; };
StepViewer.extractProps = ({ attrs }) => { StepViewer.extractProps = ({attrs}) => {
return { return {
url: attrs.options.url, url: attrs.options.url,
}; };

View File

@@ -2,37 +2,42 @@
<templates xml:space="preserve"> <templates xml:space="preserve">
<t t-name="web_widget_model_viewer.BinaryField3d" owl="1"> <t t-name="web_widget_model_viewer.BinaryField3d" owl="1">
<model-viewer <t t-if="props.value">
t-att-src='props.url' <model-viewer
name="3D model" t-att-src='props.url'
alt="3D model" name="3D model"
auto-rotate="1" alt="3D model"
camera-controls="1" auto-rotate="1"
style ="background-color: #0D1D54;" camera-controls="1"
> style="background-color: #0D1D54;"
>
<!-- <div class="text-center mt-4 mb-4 mr-4">--> <!-- <div class="text-center mt-4 mb-4 mr-4">-->
<!-- <span--> <!-- <span-->
<!-- id="model-viewer-fullscreen"--> <!-- id="model-viewer-fullscreen"-->
<!-- title="View fullscreen"--> <!-- title="View fullscreen"-->
<!-- role="img"--> <!-- role="img"-->
<!-- aria-label="Fullscreen"--> <!-- aria-label="Fullscreen"-->
<!-- >--> <!-- >-->
<!-- <i class="fa fa-arrows-alt fa-2x"/>--> <!-- <i class="fa fa-arrows-alt fa-2x"/>-->
<!-- </span>--> <!-- </span>-->
<!-- </div>--> <!-- </div>-->
</model-viewer> </model-viewer>
</t>
<!-- <model-viewer--> <t t-if="!props.value">
<!-- src='/jikimo_model_viewer/static/src/js/3d_viewer/test.glb'--> <div style="color:#D23F3A">当前制造订单暂无模型</div>
<!-- name="Test 3D model"--> </t>
<!-- alt="Test 3D model"-->
<!-- auto-rotate="1"--> <!-- <model-viewer-->
<!-- camera-controls="1"--> <!-- src='/jikimo_model_viewer/static/src/js/3d_viewer/test.glb'-->
<!-- />--> <!-- name="Test 3D model"-->
<!-- alt="Test 3D model"-->
<!-- auto-rotate="1"-->
<!-- camera-controls="1"-->
<!-- />-->
<script type="module" <script type="module"
src="/web_widget_model_viewer/static/src/lib/model-viewer.min.js"> src="/web_widget_model_viewer/static/src/lib/model-viewer.min.js">
</script> </script>
</t> </t>