$PBExportHeader$uo_fx_saletask_custom_tab.sru
forward
global type uo_fx_saletask_custom_tab from tab
end type
type tabpage_fj from userobject within uo_fx_saletask_custom_tab
end type
type cb_fj_commit from commandbutton within tabpage_fj
end type
type dw_fj from u_dw_rbtnfilter within tabpage_fj
end type
type cb_fj_del from commandbutton within tabpage_fj
end type
type cb_fj_upload from commandbutton within tabpage_fj
end type
type cbx_fj_ch_all from checkbox within tabpage_fj
end type
type tabpage_fj from userobject within uo_fx_saletask_custom_tab
cb_fj_commit cb_fj_commit
dw_fj dw_fj
cb_fj_del cb_fj_del
cb_fj_upload cb_fj_upload
cbx_fj_ch_all cbx_fj_ch_all
end type
type tabpage_fymx from userobject within uo_fx_saletask_custom_tab
end type
type dw_fymx from u_dw_rbtnfilter within tabpage_fymx
end type
type tabpage_fymx from userobject within uo_fx_saletask_custom_tab
dw_fymx dw_fymx
end type
type tabpage_sfxm from userobject within uo_fx_saletask_custom_tab
end type
type dw_sfxm from u_dw_rbtnfilter within tabpage_sfxm
end type
type tabpage_sfxm from userobject within uo_fx_saletask_custom_tab
dw_sfxm dw_sfxm
end type
type tabpage_barcode from userobject within uo_fx_saletask_custom_tab
end type
type dw_barcode from u_dw_rbtnfilter within tabpage_barcode
end type
type tabpage_barcode from userobject within uo_fx_saletask_custom_tab
dw_barcode dw_barcode
end type
type tabpage_log from userobject within uo_fx_saletask_custom_tab
end type
type dw_log from u_dw_rbtnfilter within tabpage_log
end type
type tabpage_log from userobject within uo_fx_saletask_custom_tab
dw_log dw_log
end type
end forward

global type uo_fx_saletask_custom_tab from tab
integer width = 2542
integer height = 1160
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long backcolor = 16777215
boolean raggedright = true
boolean focusonbuttondown = true
integer selectedtab = 1
tabpage_fj tabpage_fj
tabpage_fymx tabpage_fymx
tabpage_sfxm tabpage_sfxm
tabpage_barcode tabpage_barcode
tabpage_log tabpage_log
event ue_resize ( )
event ue_init ( long a_taskid,  long a_status,  window a_parent )
event ue_tab_fj_del ( long a_printid )
event ue_init_with_tid ( long a_taskid,  long a_status,  string a_tid,  window a_parent )
end type
global uo_fx_saletask_custom_tab uo_fx_saletask_custom_tab

type variables
long ins_taskid, ins_status
string ins_tid
window ins_parent
end variables

forward prototypes
public subroutine wf_retr (boolean a_ifforce)
public subroutine wf_retr_fj ()
public subroutine wf_retr_fymx ()
public subroutine wf_retr_sfxm ()
public subroutine wf_retr_barcode ()
public subroutine wf_retr_log ()
public subroutine wf_open ()
end prototypes

event ue_resize();// 附件
tabpage_fj.dw_fj.Width = tabpage_fj.Width
tabpage_fj.dw_fj.Height = tabpage_fj.Height - tabpage_fj.dw_fj.Y

// 费用明细
tabpage_fymx.dw_fymx.Width = tabpage_fymx.Width
tabpage_fymx.dw_fymx.Height = tabpage_fymx.Height - tabpage_fymx.dw_fymx.Y

// 收费项目
tabpage_sfxm.dw_sfxm.Width = tabpage_sfxm.Width
tabpage_sfxm.dw_sfxm.Height = tabpage_sfxm.Height - tabpage_sfxm.dw_sfxm.Y

// 条码
tabpage_barcode.dw_barcode.Width = tabpage_barcode.Width
tabpage_barcode.dw_barcode.Height = tabpage_barcode.Height - tabpage_barcode.dw_barcode.Y

// 日志
tabpage_log.dw_log.Width = tabpage_log.Width
tabpage_log.dw_log.Height = tabpage_log.Height - tabpage_log.dw_log.Y
end event

event ue_init(long a_taskid, long a_status, window a_parent);post event ue_init_with_tid(a_taskid, a_status, '', a_parent)

end event

event ue_tab_fj_del(long a_printid);// 删除订单明细，触发删除对应附件事件
// a_printid--订单明细printid

long ll_findRow, ll_index = 0
long ll_arr_rows[]
string ls_findStr = 'mxprintid = ' + string(a_printid)
ls_findStr = 'mxprintid = ' + string(a_printid)

ll_findRow = tabpage_fj.dw_fj.Find(ls_findStr, 1, tabpage_fj.dw_fj.RowCount())
do while (ll_findRow > 0)
	ll_index++
	ll_arr_rows[ll_index] = ll_findRow
	
	if (ll_findRow + 1 > tabpage_fj.dw_fj.RowCount()) then exit
	ll_findRow = tabpage_fj.dw_fj.Find(ls_findStr, ll_findRow + 1, tabpage_fj.dw_fj.RowCount())
loop

if (ll_index > 0) then
	// 退回状态，删除明细，重新添加明细，添加附件，不需要删除fx_saletask_fj，保存接口会处理
	
	for ll_index = UpperBound(ll_arr_rows) to 1 step - 1
		tabpage_fj.dw_fj.DeleteRow(ll_arr_rows[ll_index])
	next
end if

end event

event ue_init_with_tid(long a_taskid, long a_status, string a_tid, window a_parent);ins_taskid = a_taskid
ins_status = a_status
ins_tid = a_tid
ins_parent = a_parent

wf_retr(true)
end event

public subroutine wf_retr (boolean a_ifforce);// 刷新当前tabpage
// a_ifforce是否强制刷新

long ll_i, ll_index
if (a_ifforce) then
	for ll_i = 1 to UpperBound(this.Control)
		this.Control[ll_i].tag = ''
	next
end if

if (IsNull(ins_taskid)) then return

ll_index = this.SelectedTab
string ls_tabtext, ls_tag
ls_tabtext = Trim(this.Control[ll_index].text)
ls_tag = Trim(this.Control[ll_index].tag)
if (ls_tag <> string(ins_taskid)) then
	//附件,费用明细,收费项目,条码,日志,包件立方
	this.Control[ll_index].tag = string(ins_taskid)
	
	if (ls_tabtext = '附件') then
		wf_retr_fj()
	elseif (ls_tabtext = '费用明细') then
		wf_retr_fymx()
	elseif (ls_tabtext = '收费项目') then
		wf_retr_sfxm()
	elseif (ls_tabtext = '条码') then
		wf_retr_barcode()
	elseif (ls_tabtext = '日志') then
		wf_retr_log()
//	elseif (ls_tabtext = '包件立方') then
		
	end if
end if

end subroutine

public subroutine wf_retr_fj ();// 刷新 附件 tab
tabpage_fj.dw_fj.Reset()

tabpage_fj.cb_fj_commit.Enabled = false

if (IsNull(ins_tid)) then return
if (Trim(ins_tid) = '') then return

string arg_msg
oleobject req, ret
req = FXAppCom.CreatePbDictionary()
req.SetString('token', app_token_fx)
req.SetString('tid', ins_tid)
ret = FXAppCom.DoExecute('GetTaskFjListByTid', req)
arg_msg = ret.GetString('ErrMsg')
if (arg_msg <> '') then
	MessageBox('提示', arg_msg)
	return
end if

oleobject list, item
list = ret.GetPBArray('list')

long ll_i, ll_insertRow
tabpage_fj.dw_fj.SetRedraw(false)
for ll_i = 1 to list.Count
	item = list.GetPBDictionary(ll_i - 1)
	
	ll_insertRow = tabpage_fj.dw_fj.InsertRow(0)
	tabpage_fj.dw_fj.Object.ch[ll_insertRow] = 0
	tabpage_fj.dw_fj.Object.mxprintid[ll_insertRow] = item.GetInt('mxprintid')
	tabpage_fj.dw_fj.Object.fjType[ll_insertRow] = item.GetInt('fjType')
	tabpage_fj.dw_fj.Object.fileName[ll_insertRow] = item.GetString('fileName')
	tabpage_fj.dw_fj.Object.dscrp[ll_insertRow] = item.GetString('dscrp')
	tabpage_fj.dw_fj.Object.opemp[ll_insertRow] = item.GetString('opemp')
	if (not IsNull(item.GetString('opdate'))) then
		tabpage_fj.dw_fj.Object.opdate[ll_insertRow] = item.GetDateTime('opdate')
	end if
	tabpage_fj.dw_fj.Object.taskid[ll_insertRow] = item.GetInt('taskid')
	tabpage_fj.dw_fj.Object.fjprintid[ll_insertRow] = item.GetInt('fjprintid')
	tabpage_fj.dw_fj.Object.fileType[ll_insertRow] = item.GetString('fileType')
	tabpage_fj.dw_fj.Object.filemd5[ll_insertRow] = item.GetString('filemd5')
	tabpage_fj.dw_fj.Object.filepath[ll_insertRow] = ''
next
tabpage_fj.dw_fj.AcceptText()
tabpage_fj.dw_fj.SetRedraw(true)


end subroutine

public subroutine wf_retr_fymx ();// 刷新 费用明细 tab
tabpage_fymx.dw_fymx.Reset()

if (IsNull(ins_taskid)) then return
if (ins_taskid <= 0) then return

string arg_msg
oleobject req, ret
req = FXAppCom.CreatePbDictionary()
req.SetString('token', app_token_fx)
req.SetString('taskid', ins_taskid)
ret = FXAppCom.DoExecute('GetCostItem', req)
arg_msg = ret.GetString('ErrMsg')
if (arg_msg <> '') then
	MessageBox('提示', arg_msg)
	return
end if

oleobject list, item
list = ret.GetPBArray('items')

long ll_i, ll_insertRow
tabpage_fymx.dw_fymx.SetRedraw(false)
for ll_i = 1 to list.Count
	item = list.GetPBDictionary(ll_i - 1)
	
	ll_insertRow = tabpage_fymx.dw_fymx.InsertRow(0)
	tabpage_fymx.dw_fymx.Object.printid[ll_insertRow] = item.GetInt('printid')
	tabpage_fymx.dw_fymx.Object.itemcode[ll_insertRow] = item.GetString('itemcode')
	tabpage_fymx.dw_fymx.Object.itemname[ll_insertRow] = item.GetString('itemname')
	tabpage_fymx.dw_fymx.Object.itemtype[ll_insertRow] = item.GetString('itemtype')
	tabpage_fymx.dw_fymx.Object.amt[ll_insertRow] = item.GetDouble('amt')
	tabpage_fymx.dw_fymx.Object.mxdscrp[ll_insertRow] = item.GetString('mxdscrp')
	tabpage_fymx.dw_fymx.Object.taskid[ll_insertRow] = item.GetInt('taskid')
next
tabpage_fymx.dw_fymx.AcceptText()
tabpage_fymx.dw_fymx.SetRedraw(true)

end subroutine

public subroutine wf_retr_sfxm ();// 刷新 收费项目 tab
tabpage_sfxm.dw_sfxm.Reset()

if (IsNull(ins_taskid)) then return
if (ins_taskid <= 0) then return

string arg_msg
oleobject req, ret
req = FXAppCom.CreatePbDictionary()
req.SetString('token', app_token_fx)
req.SetString('taskid', ins_taskid)
ret = FXAppCom.DoExecute('GetSaletaskPriceItemmx', req)
arg_msg = ret.GetString('ErrMsg')
if (arg_msg <> '') then
	MessageBox('提示', arg_msg)
	return
end if

oleobject list, item
list = ret.GetPBArray('list')

long ll_i, ll_insertRow
tabpage_sfxm.dw_sfxm.SetRedraw(false)
for ll_i = 1 to list.Count
	item = list.GetPBDictionary(ll_i - 1)
	
	ll_insertRow = tabpage_sfxm.dw_sfxm.InsertRow(0)
	tabpage_sfxm.dw_sfxm.Object.pid[ll_insertRow] = item.GetInt('pid')
	tabpage_sfxm.dw_sfxm.Object.itemcode[ll_insertRow] = item.GetString('itemcode')
	tabpage_sfxm.dw_sfxm.Object.itemname[ll_insertRow] = item.GetString('itemname')
	tabpage_sfxm.dw_sfxm.Object.subitemname[ll_insertRow] = item.GetString('subitemname')
	tabpage_sfxm.dw_sfxm.Object.calcType[ll_insertRow] = item.GetInt('calcType')
	tabpage_sfxm.dw_sfxm.Object.qty[ll_insertRow] = item.GetDouble('qty')
	tabpage_sfxm.dw_sfxm.Object.itemvalue[ll_insertRow] = item.GetDouble('itemvalue')
	tabpage_sfxm.dw_sfxm.Object.unit[ll_insertRow] = item.GetString('unit')
	tabpage_sfxm.dw_sfxm.Object.taskid[ll_insertRow] = item.GetInt('taskid')
	tabpage_sfxm.dw_sfxm.Object.printid[ll_insertRow] = item.GetInt('printid')
	tabpage_sfxm.dw_sfxm.Object.ifdft[ll_insertRow] = item.GetInt('ifdft')
	tabpage_sfxm.dw_sfxm.Object.p1[ll_insertRow] = item.GetString('p1')
	tabpage_sfxm.dw_sfxm.Object.p2[ll_insertRow] = item.GetString('p2')
	tabpage_sfxm.dw_sfxm.Object.p3[ll_insertRow] = item.GetString('p3')
	tabpage_sfxm.dw_sfxm.Object.rate[ll_insertRow] = item.GetDouble('rate')
	tabpage_sfxm.dw_sfxm.Object.dscrp[ll_insertRow] = item.GetString('dscrp')
	tabpage_sfxm.dw_sfxm.Object.priceDscrp[ll_insertRow] = item.GetString('priceDscrp')
	tabpage_sfxm.dw_sfxm.Object.method[ll_insertRow] = item.GetString('method')
next
tabpage_sfxm.dw_sfxm.AcceptText()
tabpage_sfxm.dw_sfxm.SetRedraw(true)

end subroutine

public subroutine wf_retr_barcode ();// 刷新 条码 tab
tabpage_barcode.dw_barcode.Reset()

if (IsNull(ins_taskid)) then return
if (ins_taskid <= 0) then return

string arg_msg
oleobject req, ret
req = FXAppCom.CreatePbDictionary()
req.SetString('token', app_token_fx)
req.SetString('taskid', ins_taskid)
ret = FXAppCom.DoExecute('GetOutwareBarcode', req)
arg_msg = ret.GetString('ErrMsg')
if (arg_msg <> '') then
	MessageBox('提示', arg_msg)
	return
end if

oleobject list, item
list = ret.GetPBArray('barcodes')

long ll_i, ll_insertRow
tabpage_barcode.dw_barcode.SetRedraw(false)
for ll_i = 1 to list.Count
	item = list.GetPBDictionary(ll_i - 1)
	
	ll_insertRow = tabpage_barcode.dw_barcode.InsertRow(0)
	tabpage_barcode.dw_barcode.Object.barcode[ll_insertRow] = item.GetString('barcode')
	tabpage_barcode.dw_barcode.Object.flag[ll_insertRow] = item.GetInt('flag')
	tabpage_barcode.dw_barcode.Object.ifcheck[ll_insertRow] = item.GetInt('ifcheck')
	tabpage_barcode.dw_barcode.Object.mtrlcode[ll_insertRow] = item.GetString('mtrlcode')
	tabpage_barcode.dw_barcode.Object.mtrlname[ll_insertRow] = item.GetString('mtrlname')
	tabpage_barcode.dw_barcode.Object.mtrlmode[ll_insertRow] = item.GetString('mtrlmode')
	tabpage_barcode.dw_barcode.Object.status[ll_insertRow] = item.GetString('status')
	tabpage_barcode.dw_barcode.Object.woodcode[ll_insertRow] = item.GetString('woodcode')
	tabpage_barcode.dw_barcode.Object.pcode[ll_insertRow] = item.GetString('pcode')
	tabpage_barcode.dw_barcode.Object.qty[ll_insertRow] = item.GetDouble('qty')
	tabpage_barcode.dw_barcode.Object.packqty[ll_insertRow] = item.GetDouble('packqty')
	tabpage_barcode.dw_barcode.Object.outwarecode[ll_insertRow] = item.GetString('outwarecode')
	if (not IsNull(item.GetDateTime('outwaredate'))) then
		tabpage_barcode.dw_barcode.Object.outwaredate[ll_insertRow] = item.GetDateTime('outwaredate')
	end if
	tabpage_barcode.dw_barcode.Object.freight_emp[ll_insertRow] = item.GetString('freight_emp')
	tabpage_barcode.dw_barcode.Object.freight_phone[ll_insertRow] = item.GetString('freight_phone')
	tabpage_barcode.dw_barcode.Object.taskid[ll_insertRow] = ins_taskid
next
tabpage_barcode.dw_barcode.AcceptText()
tabpage_barcode.dw_barcode.SetRedraw(true)

end subroutine

public subroutine wf_retr_log ();// 刷新 日志 tab
tabpage_log.dw_log.Reset()

if (IsNull(ins_taskid)) then return
if (ins_taskid <= 0) then return

string arg_msg
oleobject req, ret
req = FXAppCom.CreatePbDictionary()
req.SetString('token', app_token_fx)
req.SetString('taskid', ins_taskid)
ret = FXAppCom.DoExecute('GetTaskLogs', req)
arg_msg = ret.GetString('ErrMsg')
if (arg_msg <> '') then
	MessageBox('提示', arg_msg)
	return
end if

oleobject list, item
list = ret.GetPBArray('logs')

long ll_i, ll_insertRow
tabpage_log.dw_log.SetRedraw(false)
for ll_i = 1 to list.Count
	item = list.GetPBDictionary(ll_i - 1)
	
	ll_insertRow = tabpage_log.dw_log.InsertRow(0)
	tabpage_log.dw_log.Object.opemp[ll_insertRow] = item.GetString('opemp')
	tabpage_log.dw_log.Object.opLog[ll_insertRow] = item.GetString('opLog')
	if (not IsNull(item.GetDateTime('opdate'))) then
		tabpage_log.dw_log.Object.opdate[ll_insertRow] = item.GetDateTime('opdate')
	end if
next
tabpage_log.dw_log.AcceptText()
tabpage_log.dw_log.SetRedraw(true)

end subroutine

public subroutine wf_open ();oleobject parm
parm = FXAppCom.CreatePbDictionary()
FXAppCom.SaveFileFromFxFileMap(parm)
end subroutine

on uo_fx_saletask_custom_tab.create
this.tabpage_fj=create tabpage_fj
this.tabpage_fymx=create tabpage_fymx
this.tabpage_sfxm=create tabpage_sfxm
this.tabpage_barcode=create tabpage_barcode
this.tabpage_log=create tabpage_log
this.Control[]={this.tabpage_fj,&
this.tabpage_fymx,&
this.tabpage_sfxm,&
this.tabpage_barcode,&
this.tabpage_log}
end on

on uo_fx_saletask_custom_tab.destroy
destroy(this.tabpage_fj)
destroy(this.tabpage_fymx)
destroy(this.tabpage_sfxm)
destroy(this.tabpage_barcode)
destroy(this.tabpage_log)
end on

event selectionchanged;wf_retr(false)
end event

type tabpage_fj from userobject within uo_fx_saletask_custom_tab
event create ( )
event destroy ( )
integer x = 18
integer y = 96
integer width = 2505
integer height = 1048
long backcolor = 16777215
string text = "附件"
long tabtextcolor = 33554432
long picturemaskcolor = 536870912
cb_fj_commit cb_fj_commit
dw_fj dw_fj
cb_fj_del cb_fj_del
cb_fj_upload cb_fj_upload
cbx_fj_ch_all cbx_fj_ch_all
end type

on tabpage_fj.create
this.cb_fj_commit=create cb_fj_commit
this.dw_fj=create dw_fj
this.cb_fj_del=create cb_fj_del
this.cb_fj_upload=create cb_fj_upload
this.cbx_fj_ch_all=create cbx_fj_ch_all
this.Control[]={this.cb_fj_commit,&
this.dw_fj,&
this.cb_fj_del,&
this.cb_fj_upload,&
this.cbx_fj_ch_all}
end on

on tabpage_fj.destroy
destroy(this.cb_fj_commit)
destroy(this.dw_fj)
destroy(this.cb_fj_del)
destroy(this.cb_fj_upload)
destroy(this.cbx_fj_ch_all)
end on

type cb_fj_commit from commandbutton within tabpage_fj
integer x = 864
integer width = 302
integer height = 84
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
boolean enabled = false
string text = "确认上传"
end type

event clicked;if (IsNull(ins_taskid)) then return
if (ins_taskid <= 0) then return
if (ins_status = 2) then return

dw_fj.AcceptText()

long ll_findRow, ll_i = 0
long ll_rows[]
string ls_findStr, arg_msg
ls_findStr = 'fjprintid <= 0'
ll_findRow = dw_fj.Find(ls_findStr, 1, dw_fj.RowCount())
do while (ll_findRow > 0)
	ll_i++
	ll_rows[ll_i] = ll_findRow
	
	if (ll_findRow + 1 > dw_fj.RowCount()) then exit
	ll_findRow = dw_fj.Find(ls_findStr, ll_findRow + 1, dw_fj.RowCount())
loop
if (UpperBound(ll_rows) <= 0) then
	MessageBox('提示', '没有需要提交的附件')
	this.Enabled = false
	return
end if

// 1-先上传新增附件的md5，与服务器对比，2-返回服务器没有的md5，再上传附件数据
string ls_arr_1_md5[], ls_arr_1_filepath[]
for ll_i = 1 to UpperBound(ll_rows)
	ls_arr_1_md5[ll_i] = dw_fj.Object.filemd5[ll_rows[ll_i]]
	ls_arr_1_filepath[ll_i] = dw_fj.Object.filepath[ll_rows[ll_i]]
next
if (UpperBound(ls_arr_1_md5) > 0) then
	if (f_chkfxfilemapwithmd5andupload(ls_arr_1_md5, ls_arr_1_filepath, ref arg_msg) <> 1) then
		MessageBox('提示', '上传失败:' + arg_msg)
		return
	end if
end if

// PC端需提供fjType、dscrp、fileName、fileType、filemd5
oleobject files, item
files = FXAppCom.NewPBArray()
for ll_i = 1 to UpperBound(ll_rows)
	ll_findRow = ll_rows[ll_i]
	item = FXAppCom.CreatePbDictionary()
	
	item.SetInt('fjType', dw_fj.Object.fjtype[ll_findRow])
	item.SetString('dscrp', Trim(dw_fj.Object.dscrp[ll_findRow]))
	item.SetString('fileName', dw_fj.Object.filename[ll_findRow])
	item.SetString('fileType', dw_fj.Object.fileType[ll_findRow])
	item.SetString('filemd5', dw_fj.Object.filemd5[ll_findRow])
	
	files.AddObject(item)
next

// 更新到fx_saletask_fj
oleobject req, rsp
req = FXAppCom.CreatePbDictionary()
req.SetString('token', app_token_fx)
req.SetInt('taskid', ins_taskid)
req.SetInt('printid', 1) // 定制产品订单只有一个明细
req.SetInt('clientMode', 2) // 客户端 0-手机 1-ERP 2-PB客户端
req.SetObject('files', files)
rsp = FXAppCom.DoExecute('UploadSaletaskFiles', req)
arg_msg = rsp.GetString('ErrMsg')
if (arg_msg <> '') then
	MessageBox('提示', arg_msg)
	return
else
	wf_retr_fj()
end if


end event

type dw_fj from u_dw_rbtnfilter within tabpage_fj
integer y = 88
integer width = 2267
integer height = 784
integer taborder = 40
string dataobject = "dw_fx_buytask_custom_fj"
boolean hscrollbar = true
boolean vscrollbar = true
boolean hsplitscroll = true
borderstyle borderstyle = stylebox!
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
end type

event clicked;call super::clicked;string ls_name, ls_filepath, ls_fileName, ls_fileType, ls_filemd5
string arg_msg, ls_retPath
oleobject parm, ret
if (row > 0) then
	this.SetRow(row)
	this.SelectRow(0, false)
	this.SelectRow(row, true)
	
	ls_name = dwo.Name
	if (ls_name = 'compute_1') then
		ls_filepath = Trim(this.Object.filepath[row])
		ls_fileName = Trim(this.Object.fileName[row])
		ls_fileType = Trim(this.Object.fileType[row])
		ls_filemd5 = Trim(this.Object.filemd5[row])
		
		parm = FXAppCom.CreatePbDictionary()
		parm.SetString('token', app_token_fx)
		parm.SetString('filepath', ls_filepath)
		parm.SetString('filemd5', ls_filemd5)
		parm.SetString('initialDirectory', '')
		parm.SetString('filter', '')
		parm.SetString('defaultExt', '')
		parm.SetString('fileName', ls_fileName)
		parm.SetInt('ifOpenAfterDownload', 1)
		
		ret = FXAppCom.SaveFileFromFxFileMap(parm)
		arg_msg = ret.GetString('ErrMsg')
		if (arg_msg <> '') then
			MessageBox('提示', arg_msg)
			return
		end if
		
		ls_retPath = ret.GetString('fullFilePath')
		if (ls_retPath <> '') then
			this.Object.filepath[row] = ls_retPath
			this.AcceptText()
		end if
	end if
end if
end event

event rowfocuschanged;call super::rowfocuschanged;if (currentrow > 0) then
	this.SetRow(currentrow)
	this.SelectRow(0, false)
	this.SelectRow(currentrow, true)
end if
end event

type cb_fj_del from commandbutton within tabpage_fj
integer x = 539
integer width = 302
integer height = 84
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "删除"
end type

event clicked;dw_fj.AcceptText()

long ll_findRow, ll_index = 0
long ll_arr_rows[]
string ls_findStr
ls_findStr = '(ch = 1) and (fjtype = 0 or fjtype = 2) and (opemp = "' + app_username + '")'
ll_findRow = dw_fj.Find(ls_findStr, 1, dw_fj.RowCount())
if (ll_findRow > 0) then // 多选
	do while (ll_findRow > 0)
		ll_index++
		ll_arr_rows[ll_index] = ll_findRow
		
		if (ll_findRow + 1 > dw_fj.RowCount()) then exit
		ll_findRow = dw_fj.Find(ls_findStr, ll_findRow + 1, dw_fj.RowCount())
	loop
else // 单选
	ll_findRow = dw_fj.GetRow()
	if (ll_findRow > 0) then
		if ((dw_fj.Object.fjtype[ll_findRow] = 0 or dw_fj.Object.fjtype[ll_findRow] = 2) &
				and (dw_fj.Object.opemp[ll_findRow] = app_username)) then
			ll_index++
			ll_arr_rows[ll_index] = ll_findRow
		end if
	end if
end if

if (ll_index <= 0) then
	MessageBox('提示', '请选中/勾选需要删除的附件~r~n只支持删除类型是"付款凭证"或"下单附件",且为当前账号上传的附件')
	return
end if

long ll_fjprintid, ll_i
oleobject deletePrintids
deletePrintids = FXAppCom.NewPBArray()
for ll_index = UpperBound(ll_arr_rows) to 1 step - 1
	ll_fjprintid = dw_fj.Object.fjprintid[ll_arr_rows[ll_index]]
	if ((ins_taskid > 0 and ins_status <> 2) and ll_fjprintid > 0) then // 非新建/退回状态的订单，删除附件操作需要即时提交
		deletePrintids.AddInt(ll_fjprintid)
	end if
	
	dw_fj.DeleteRow(ll_arr_rows[ll_index])
next

// 提交需要即时删除的附件，更新到fx_saletask_fj
oleobject req, rsp
string arg_msg
if (deletePrintids.Count > 0) then
	if (MessageBox('提示', '确认删除当前已上传的附件？', Question!, YesNo!) <> 1) then
		wf_retr_fj()
		return
	end if
	
	req = FXAppCom.CreatePbDictionary()
	req.SetString('token', app_token_fx)
	req.SetInt('taskid', ins_taskid)
	req.SetInt('printid', 1) // 定制产品订单只有一个明细
	req.SetInt('clientMode', 2) // 客户端 0-手机 1-ERP 2-PB客户端
	req.SetObject('deletePrintids', deletePrintids)
	rsp = FXAppCom.DoExecute('UploadSaletaskFiles', req)
	arg_msg = rsp.GetString('ErrMsg')
	if (arg_msg <> '') then
		MessageBox('提示', arg_msg)
		return
	else
		wf_retr_fj()
	end if
end if


end event

type cb_fj_upload from commandbutton within tabpage_fj
integer x = 215
integer width = 302
integer height = 84
integer taborder = 20
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "上传..."
end type

event clicked;// 新建状态可以选多个订单明细，上传附件需要对应当前的明细
ins_parent.PostEvent('ue_tab_fj_upload')

// 非新建、非退回状态的订单，需要手动提交附件
if (ins_taskid > 0 and ins_status <> 2) then
	cb_fj_commit.Enabled = true
end if
end event

type cbx_fj_ch_all from checkbox within tabpage_fj
integer x = 9
integer y = 12
integer width = 192
integer height = 60
integer taborder = 10
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 16777215
string text = "全选"
end type

event clicked;long ll_ch, ll_i
if (this.Checked) then
	ll_ch = 1
else
	ll_ch = 0
end if

for ll_i = 1 to dw_fj.RowCount()
	dw_fj.Object.ch[ll_i] = ll_ch
next
dw_fj.AcceptText()
end event

type tabpage_fymx from userobject within uo_fx_saletask_custom_tab
event create ( )
event destroy ( )
integer x = 18
integer y = 96
integer width = 2505
integer height = 1048
long backcolor = 16777215
string text = "费用明细"
long tabtextcolor = 33554432
long tabbackcolor = 16777215
long picturemaskcolor = 536870912
dw_fymx dw_fymx
end type

on tabpage_fymx.create
this.dw_fymx=create dw_fymx
this.Control[]={this.dw_fymx}
end on

on tabpage_fymx.destroy
destroy(this.dw_fymx)
end on

type dw_fymx from u_dw_rbtnfilter within tabpage_fymx
integer width = 2126
integer height = 700
integer taborder = 20
string dataobject = "dw_fx_buytask_itemmx"
boolean hscrollbar = true
boolean vscrollbar = true
boolean hsplitscroll = true
borderstyle borderstyle = stylebox!
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
end type

event clicked;call super::clicked;if (row > 0) then
	this.SetRow(row)
	this.SelectRow(0, false)
	this.SelectRow(row, true)
end if
end event

event rowfocuschanged;call super::rowfocuschanged;if (currentrow > 0) then
	this.SetRow(currentrow)
	this.SelectRow(0, false)
	this.SelectRow(currentrow, true)
end if
end event

type tabpage_sfxm from userobject within uo_fx_saletask_custom_tab
event create ( )
event destroy ( )
integer x = 18
integer y = 96
integer width = 2505
integer height = 1048
long backcolor = 16777215
string text = "收费项目"
long tabtextcolor = 33554432
long tabbackcolor = 16777215
long picturemaskcolor = 536870912
dw_sfxm dw_sfxm
end type

on tabpage_sfxm.create
this.dw_sfxm=create dw_sfxm
this.Control[]={this.dw_sfxm}
end on

on tabpage_sfxm.destroy
destroy(this.dw_sfxm)
end on

type dw_sfxm from u_dw_rbtnfilter within tabpage_sfxm
integer width = 1947
integer height = 780
integer taborder = 20
string dataobject = "dw_fx_saletask_price_itemmx"
boolean hscrollbar = true
boolean vscrollbar = true
boolean hsplitscroll = true
borderstyle borderstyle = stylebox!
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
end type

type tabpage_barcode from userobject within uo_fx_saletask_custom_tab
event create ( )
event destroy ( )
integer x = 18
integer y = 96
integer width = 2505
integer height = 1048
long backcolor = 16777215
string text = "条码"
long tabtextcolor = 33554432
long tabbackcolor = 16777215
long picturemaskcolor = 536870912
dw_barcode dw_barcode
end type

on tabpage_barcode.create
this.dw_barcode=create dw_barcode
this.Control[]={this.dw_barcode}
end on

on tabpage_barcode.destroy
destroy(this.dw_barcode)
end on

type dw_barcode from u_dw_rbtnfilter within tabpage_barcode
integer width = 2117
integer height = 788
integer taborder = 20
string dataobject = "dw_fx_outware_barcode"
boolean hscrollbar = true
boolean vscrollbar = true
boolean hsplitscroll = true
borderstyle borderstyle = stylebox!
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
end type

type tabpage_log from userobject within uo_fx_saletask_custom_tab
event create ( )
event destroy ( )
integer x = 18
integer y = 96
integer width = 2505
integer height = 1048
long backcolor = 16777215
string text = "日志"
long tabtextcolor = 33554432
long tabbackcolor = 16777215
long picturemaskcolor = 536870912
dw_log dw_log
end type

on tabpage_log.create
this.dw_log=create dw_log
this.Control[]={this.dw_log}
end on

on tabpage_log.destroy
destroy(this.dw_log)
end on

type dw_log from u_dw_rbtnfilter within tabpage_log
integer width = 2281
integer height = 796
integer taborder = 20
string dataobject = "dw_fx_saletask_log"
boolean hscrollbar = true
boolean vscrollbar = true
boolean hsplitscroll = true
borderstyle borderstyle = stylebox!
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
end type

