修改传参,增加提示,默认展示第一个文件
This commit is contained in:
@@ -10,7 +10,8 @@ odoo.define('sf_demand.print_demand', function (require) {
|
|||||||
var CustomListRenderer = ListRenderer.extend({
|
var CustomListRenderer = ListRenderer.extend({
|
||||||
_render: function () {
|
_render: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.getParent()?.$buttons.hide()
|
this.getParent()?.$buttons.hide();
|
||||||
|
|
||||||
return this._super.apply(this, arguments).then(function () {
|
return this._super.apply(this, arguments).then(function () {
|
||||||
// 添加图片预览容器到页面左侧
|
// 添加图片预览容器到页面左侧
|
||||||
if (!$('.table-image-preview-container').length) {
|
if (!$('.table-image-preview-container').length) {
|
||||||
@@ -34,7 +35,12 @@ odoo.define('sf_demand.print_demand', function (require) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
start: function() {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$el.find('.o_data_row').eq(0).trigger('click')
|
||||||
|
}, 500);
|
||||||
|
return this._super();
|
||||||
|
},
|
||||||
events: _.extend({}, ListRenderer.prototype.events, {
|
events: _.extend({}, ListRenderer.prototype.events, {
|
||||||
'click .o_data_row': '_onCustomRowClick',
|
'click .o_data_row': '_onCustomRowClick',
|
||||||
'click .o_print_custom': '_onPrintClick',
|
'click .o_print_custom': '_onPrintClick',
|
||||||
@@ -48,7 +54,6 @@ odoo.define('sf_demand.print_demand', function (require) {
|
|||||||
var $row = $(ev.currentTarget);
|
var $row = $(ev.currentTarget);
|
||||||
var index = $row.index();
|
var index = $row.index();
|
||||||
var data = this.state.data[index];
|
var data = this.state.data[index];
|
||||||
console.log(this, 'this', data);
|
|
||||||
if(data.fileData?.fileUrl) {
|
if(data.fileData?.fileUrl) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -71,7 +76,6 @@ odoo.define('sf_demand.print_demand', function (require) {
|
|||||||
Object.assign(data.fileData, attachment)
|
Object.assign(data.fileData, attachment)
|
||||||
this._getTypeInfo(attachment.mimetype, data.fileData)
|
this._getTypeInfo(attachment.mimetype, data.fileData)
|
||||||
}
|
}
|
||||||
console.log(data, 'data', attachment);
|
|
||||||
const fileUrl = this.getFileUrl(data.fileData.attachment_type, data, key)
|
const fileUrl = this.getFileUrl(data.fileData.attachment_type, data, key)
|
||||||
data.fileData.fileUrl = fileUrl
|
data.fileData.fileUrl = fileUrl
|
||||||
}
|
}
|
||||||
@@ -90,22 +94,28 @@ odoo.define('sf_demand.print_demand', function (require) {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
_onPrintClick(e) {
|
_onPrintClick(e) {
|
||||||
console.log(e, 'asdsadadsadasdad', this);
|
|
||||||
var print_ids = this.getSelectedIds();
|
var print_ids = this.getSelectedIds();
|
||||||
|
|
||||||
console.log(print_ids);
|
|
||||||
|
|
||||||
this._rpc({
|
this._rpc({
|
||||||
model: 'sf.demand.plan.print.wizard',
|
model: 'sf.demand.plan.print.wizard',
|
||||||
method: 'demand_plan_print',
|
method: 'demand_plan_print',
|
||||||
kwargs: print_ids,
|
args: [ print_ids ] ,
|
||||||
// context: this.state.getContext()
|
// context: this.state.getContext()
|
||||||
}).then(function() {
|
}).then((e) => {
|
||||||
self.do_notify("成功", "打印任务已发送到打印机");
|
|
||||||
|
this.getParent()?.getParent()?.env.services?.notification.notify( {
|
||||||
|
type: 'info',
|
||||||
|
message: e.message,
|
||||||
|
})
|
||||||
|
// self.do_notify("成功", "打印任务已发送到打印机");
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
console.error("打印错误:", error);
|
console.error("打印错误:", error);
|
||||||
self.do_warn("打印失败", error.data.message || "未知错误");
|
// self.do_warn("打印失败", error.data.message || "未知错误");
|
||||||
});
|
}).finally(e => {
|
||||||
|
this.getParent().reload()
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
},
|
},
|
||||||
getFileUrl(attachment_type, data, key) {
|
getFileUrl(attachment_type, data, key) {
|
||||||
|
|||||||
Reference in New Issue
Block a user