Accept Merge Request #681: (feature/制造代码优化 -> develop)
Merge Request: 优化js代码过长的问题,优化未用到的变量 Created By: @马广威 Accepted By: @马广威 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/681?initial=true
This commit is contained in:
@@ -45,7 +45,8 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', {
|
||||
|
||||
setDefaultColumnWidths(column_num) {
|
||||
// const bbb = this.state.columns[0].name
|
||||
const widths = this.state.columns.map((col) => this.calculateColumnWidth(col));
|
||||
const widths = this.state.columns.map((col) =>
|
||||
this.calculateColumnWidth(col));
|
||||
// const sumOfRelativeWidths = (widths
|
||||
// .filter(({ type }) => type === "relative")
|
||||
// .reduce((sum, { value }) => sum + value, 0));
|
||||
@@ -65,16 +66,19 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', {
|
||||
// }
|
||||
|
||||
// 判断 this.state.columns 是否存在且长度大于零
|
||||
if (this.state.columns && this.state.columns.length > 0 && this.state.columns[0].name === "sequence") {
|
||||
if (this.state.columns && this.state.columns.length > 0 &&
|
||||
this.state.columns[0].name === "sequence") {
|
||||
widths[1] = { type: "relative", value: 0.1 };
|
||||
}
|
||||
|
||||
|
||||
// 1 because nth-child selectors are 1-indexed, 2 when the first column contains
|
||||
// 1 because nth-child selectors are 1-indexed,
|
||||
// 2 when the first column contains
|
||||
// the checkboxes to select records.
|
||||
const columnOffset = this.hasSelectors ? 2 : 1;
|
||||
widths.forEach(({ type, value }, i) => {
|
||||
const headerEl = this.tableRef.el.querySelector(`th:nth-child(${i + columnOffset})`);
|
||||
widths.forEach(({ type, value }, width) => {
|
||||
const headerEl = this.tableRef.el.querySelector(
|
||||
`th:nth-child(${width + columnOffset})`);
|
||||
if (type === "absolute") {
|
||||
if (this.isEmpty) {
|
||||
headerEl.style.width = value;
|
||||
@@ -82,7 +86,8 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', {
|
||||
headerEl.style.minWidth = value;
|
||||
}
|
||||
} else if (type === "relative" && this.isEmpty) {
|
||||
headerEl.style.width = `${((value / column_num) * 100).toFixed(2)}%`;
|
||||
headerEl.style.width = `${((value / column_num) * 100
|
||||
).toFixed(2)}%`;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { browser } from "@web/core/browser/browser";
|
||||
import * as BarcodeScanner from "@web/webclient/barcode/barcode_scanner";
|
||||
// import { browser } from "@web/core/browser/browser";
|
||||
// import * as BarcodeScanner from "@web/webclient/barcode/barcode_scanner";
|
||||
const { Component } = owl;
|
||||
import { standardFieldProps } from "@web/views/fields/standard_field_props";
|
||||
import {registry} from "@web/core/registry";
|
||||
@@ -23,19 +23,19 @@ export class CodeField extends Component {
|
||||
this.record = this.props.record;
|
||||
}
|
||||
|
||||
async onBarcodeBtnClick() {
|
||||
const barcode = await BarcodeScanner.scanBarcode();
|
||||
if (barcode) {
|
||||
await this.onBarcodeScanned(barcode);
|
||||
if ("vibrate" in browser.navigator) {
|
||||
browser.navigator.vibrate(100);
|
||||
}
|
||||
} else {
|
||||
this.notification.add(this.env._t("Please, scan again !"), {
|
||||
type: "warning",
|
||||
});
|
||||
}
|
||||
}
|
||||
// async onBarcodeBtnClick() {
|
||||
// const barcode = await BarcodeScanner.scanBarcode();
|
||||
// if (barcode) {
|
||||
// await this.onBarcodeScanned(barcode);
|
||||
// if ("vibrate" in browser.navigator) {
|
||||
// browser.navigator.vibrate(100);
|
||||
// }
|
||||
// } else {
|
||||
// this.notification.add(this.env._t("Please, scan again !"), {
|
||||
// type: "warning",
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
async search(barcode) {
|
||||
// alert('我是search')
|
||||
const domain = [["code", "=", barcode]];
|
||||
@@ -65,33 +65,33 @@ export class CodeField extends Component {
|
||||
// console.log('currentModel',this)
|
||||
// console.log('this.record.data',this.record.data)
|
||||
// console.log('this.record.data.id', this.record.data.id)
|
||||
const workorder = await this.orm.call('mrp.workorder', 'read', [this.record.data.id]);
|
||||
// const workorder = await this.orm.call('mrp.workorder', 'read', [this.record.data.id]);
|
||||
// console.log('workorder', workorder[0])
|
||||
const updatedRecord = await this.orm.call("sf.tray", "write", [
|
||||
[records[0].id],
|
||||
{
|
||||
state: "占用",
|
||||
workorder_id: workorder[0].id,
|
||||
production_id: workorder[0].product_id[0],
|
||||
// workorder_id: workorder.id,
|
||||
}]);
|
||||
// const updatedRecord = await this.orm.call("sf.tray", "write", [
|
||||
// [records[0].id],
|
||||
// {
|
||||
// state: "占用",
|
||||
// workorder_id: workorder[0].id,
|
||||
// production_id: workorder[0].product_id[0],
|
||||
// // workorder_id: workorder.id,
|
||||
// }]);
|
||||
// console.log(workorder[0].routing_type);
|
||||
// console.log(workorder[0].production_id);
|
||||
// const productionIDS = await this.orm.call('mrp.production', 'search', [[['id', '=', workorder[0].production_id[0]]]]);
|
||||
const productionIDS = await this.orm.call('mrp.workorder', 'search', [[["production_id", "=", workorder[0].production_id[0]]]]);
|
||||
// const productionIDS = await this.orm.call('mrp.workorder', 'search', [[["production_id", "=", workorder[0].production_id[0]]]]);
|
||||
// console.log('prooooooo', productionIDS);
|
||||
// console.log('values', records[0].values[0]);
|
||||
productionIDS.forEach(async (data) => {
|
||||
// 处理每一个数据
|
||||
// console.log(data);
|
||||
const updatetrayRecord = await this.orm.call("mrp.workorder", "write", [
|
||||
[data],
|
||||
{
|
||||
tray_id: records[0].values[0].id,
|
||||
// tray_id: false,
|
||||
}]);
|
||||
// console.log(updatetrayRecord)
|
||||
});
|
||||
// productionIDS.forEach(async (data) => {
|
||||
// // 处理每一个数据
|
||||
// // console.log(data);
|
||||
// const updatetrayRecord = await this.orm.call("mrp.workorder", "write", [
|
||||
// [data],
|
||||
// {
|
||||
// tray_id: records[0].values[0].id,
|
||||
// // tray_id: false,
|
||||
// }]);
|
||||
// // console.log(updatetrayRecord)
|
||||
// });
|
||||
this.props.update(records[0].code);
|
||||
$('.o_form_button_save').click();
|
||||
} else {
|
||||
|
||||
@@ -21,7 +21,8 @@ class CustomKanbanController extends KanbanController {
|
||||
// console.log(typeof this.workOrders);
|
||||
// console.log(Array.isArray(this.workOrders));
|
||||
//
|
||||
// console.log(this.workOrders.every(order => typeof order === 'object' && order.id !== undefined));
|
||||
// console.log(this.workOrders.every(order =>
|
||||
// typeof order === 'object' && order.id !== undefined));
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
# -*-coding:utf-8-*-
|
||||
from . import models
|
||||
|
||||
|
||||
Reference in New Issue
Block a user