w_buytask_custom_view_fx.srw 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869
  1. $PBExportHeader$w_buytask_custom_view_fx.srw
  2. $PBExportComments$定制产品销售订单(查看/编辑)
  3. forward
  4. global type w_buytask_custom_view_fx from w_publ_base
  5. end type
  6. type cb_addmx from commandbutton within w_buytask_custom_view_fx
  7. end type
  8. type cb_delmx from commandbutton within w_buytask_custom_view_fx
  9. end type
  10. type uo_tab from uo_fx_saletask_custom_tab within w_buytask_custom_view_fx
  11. end type
  12. type uo_tab from uo_fx_saletask_custom_tab within w_buytask_custom_view_fx
  13. end type
  14. type dw_main from datawindow within w_buytask_custom_view_fx
  15. end type
  16. type dw_mx from u_dw_rbtnfilter within w_buytask_custom_view_fx
  17. end type
  18. end forward
  19. global type w_buytask_custom_view_fx from w_publ_base
  20. integer width = 3666
  21. integer height = 2800
  22. string title = "定制产品销售订单"
  23. boolean minbox = false
  24. windowtype windowtype = response!
  25. long backcolor = 16777215
  26. boolean center = true
  27. event ue_tab_fj_upload ( )
  28. cb_addmx cb_addmx
  29. cb_delmx cb_delmx
  30. uo_tab uo_tab
  31. dw_main dw_main
  32. dw_mx dw_mx
  33. end type
  34. global w_buytask_custom_view_fx w_buytask_custom_view_fx
  35. type variables
  36. s_fx_saletask ins_tran
  37. long ins_mxPrintid = 0 // 新建订单时,记录订单明细当前最大明细数
  38. long ins_ret = 0 // 关闭时,父窗口 0-无需刷新 1-刷新
  39. end variables
  40. forward prototypes
  41. private subroutine wf_address_ch ()
  42. private subroutine wf_add_mx ()
  43. private subroutine wf_taborder ()
  44. private subroutine wf_face ()
  45. public function integer wf_save (s_fx_saletask a_tran, ref string arg_msg)
  46. private subroutine wf_add_saletask (long a_mode)
  47. public subroutine wf_add_saletaskmx ()
  48. public function integer wf_cancel (string a_reason, ref string arg_msg)
  49. end prototypes
  50. event ue_tab_fj_upload();// uo_tab附件页【上传】按钮事件
  51. long ll_row, ll_printid, ll_dftFjtype
  52. ll_row = dw_mx.GetRow()
  53. if (ll_row <= 0) then
  54. MessageBox('提示', '请选择订单明细以确定上传附件的对应明细项')
  55. return
  56. end if
  57. ll_printid = dw_mx.Object.printid[ll_row]
  58. if (ins_tran.status <> 4) then // 非待付款状态
  59. ll_dftFjtype = 2 // 下单附件
  60. else
  61. ll_dftFjtype = 0 // 付款凭证
  62. end if
  63. OpenWithParm(w_fjtype_ch_fx, ll_dftFjtype)
  64. ll_dftFjtype = Message.DoubleParm
  65. if (ll_dftFjtype = - 1) then return
  66. oleobject parm, ret, fullNamesArr, namesArr, extsArr, md5sArr
  67. parm = FXAppCom.CreatePbDictionary()
  68. parm.SetString('filter', '')
  69. parm.SetString('ifMulti', 1)
  70. ret = FXAppCom.OpenFiles(parm)
  71. long ll_cnt, ll_insertRow, ll_i
  72. datetime ldt_now = DateTime(Today(), Now())
  73. string ls_md5s_arr[], ls_filepaths_arr[]
  74. ll_cnt = ret.GetInt('cnt')
  75. if (ll_cnt > 0) then
  76. fullNamesArr = ret.GetPBArray('fullNamesArr')
  77. namesArr = ret.GetPBArray('namesArr')
  78. extsArr = ret.GetPBArray('extsArr')
  79. md5sArr = ret.GetPBArray('md5sArr')
  80. uo_tab.tabpage_fj.dw_fj.SetRedraw(false)
  81. for ll_i = 1 to ll_cnt
  82. ll_insertRow = uo_tab.tabpage_fj.dw_fj.InsertRow(0)
  83. uo_tab.tabpage_fj.dw_fj.Object.mxprintid[ll_insertRow] = ll_printid
  84. uo_tab.tabpage_fj.dw_fj.Object.fjtype[ll_insertRow] = ll_dftFjtype
  85. uo_tab.tabpage_fj.dw_fj.Object.filename[ll_insertRow] = namesArr.GetString(ll_i - 1)
  86. uo_tab.tabpage_fj.dw_fj.Object.dscrp[ll_insertRow] = ''
  87. uo_tab.tabpage_fj.dw_fj.Object.opemp[ll_insertRow] = app_username
  88. uo_tab.tabpage_fj.dw_fj.Object.opdate[ll_insertRow] = ldt_now
  89. uo_tab.tabpage_fj.dw_fj.Object.ch[ll_insertRow] = 0
  90. uo_tab.tabpage_fj.dw_fj.Object.fjprintid[ll_insertRow] = 0
  91. uo_tab.tabpage_fj.dw_fj.Object.fileType[ll_insertRow] = extsArr.GetString(ll_i - 1)
  92. uo_tab.tabpage_fj.dw_fj.Object.filemd5[ll_insertRow] = md5sArr.GetString(ll_i - 1)
  93. uo_tab.tabpage_fj.dw_fj.Object.filepath[ll_insertRow] = fullNamesArr.GetString(ll_i - 1)
  94. ls_md5s_arr[ll_i] = md5sArr.GetString(ll_i - 1)
  95. ls_filepaths_arr[ll_i] = fullNamesArr.GetString(ll_i - 1)
  96. next
  97. uo_tab.tabpage_fj.dw_fj.AcceptText()
  98. uo_tab.tabpage_fj.dw_fj.SetRedraw(true)
  99. ins_ret = 1
  100. end if
  101. end event
  102. private subroutine wf_address_ch ();// 收货人地址选择
  103. long ll_row
  104. ll_row = dw_main.GetRow()
  105. if (ll_row <= 0) then return
  106. s_fx_address s_tran
  107. Open(w_address_ch_fx)
  108. s_tran = Message.PowerObjectParm
  109. if (not IsNull(s_tran)) then
  110. if (IsValid(s_tran)) then
  111. if (s_tran.addressid > 0) then
  112. dw_main.Object.addressid[ll_row] = s_tran.addressid
  113. dw_main.Object.cus_rep[ll_row] = s_tran.cus_rep
  114. dw_main.Object.cus_tele[ll_row] = s_tran.cus_tele
  115. dw_main.Object.cus_address[ll_row] = s_tran.cus_address
  116. dw_main.AcceptText()
  117. end if
  118. end if
  119. end if
  120. end subroutine
  121. private subroutine wf_add_mx ();// 添加明细
  122. if (not if_modify_mode) then return
  123. if (ins_tran.taskid > 0 and dw_mx.RowCount() >= 1) then return
  124. s_fx_mtrldef s_tran
  125. Open(w_mtrl_custom_ch_by_sptcomid_fx)
  126. s_tran = Message.PowerObjectParm
  127. if (IsNull(s_tran)) then return
  128. if (not IsValid(s_tran)) then return
  129. if (not s_tran.ifselect) then return
  130. long ll_i, ll_insertRow
  131. dw_mx.SetRedraw(false)
  132. for ll_i = 1 to UpperBound(s_tran.fxmtrlid)
  133. ll_insertRow = dw_mx.InsertRow(0)
  134. ins_mxPrintid++
  135. dw_mx.Object.printid[ll_insertRow] = ins_mxPrintid
  136. dw_mx.Object.mb_mtrlcode[ll_insertRow] = s_tran.mtrlcode[ll_i]
  137. dw_mx.Object.mb_mtrlname[ll_insertRow] = s_tran.mtrlname[ll_i]
  138. dw_mx.Object.mb_mtrlmode[ll_insertRow] = s_tran.mtrlmode[ll_i]
  139. dw_mx.Object.qty[ll_insertRow] = 1
  140. dw_mx.Object.requiredate[ll_insertRow] = DateTime(Today(), Now())
  141. dw_mx.Object.mxdscrp[ll_insertRow] = ''
  142. dw_mx.Object.mxdscrp2[ll_insertRow] = ''
  143. dw_mx.Object.fxmtrlid_ori[ll_insertRow] = s_tran.fxmtrlid[ll_i]
  144. dw_mx.Object.fxmtrlid[ll_insertRow] = s_tran.fxmtrlid[ll_i]
  145. dw_mx.Object.mtrlid_ori[ll_insertRow] = s_tran.mtrlid[ll_i]
  146. dw_mx.Object.mtrlid[ll_insertRow] = s_tran.mtrlid[ll_i]
  147. // dw_mx.Object.status[ll_insertRow] = ''
  148. // dw_mx.Object.woodcode[ll_insertRow] = ''
  149. // dw_mx.Object.pcode[ll_insertRow] = ''
  150. next
  151. dw_mx.AcceptText()
  152. dw_mx.SetRedraw(true)
  153. end subroutine
  154. private subroutine wf_taborder ();//
  155. long ll_i, ll_step
  156. if (if_modify_mode) then
  157. ll_step = 10
  158. else
  159. ll_step = 0
  160. end if
  161. ll_i = 0
  162. ll_i += ll_step
  163. dw_mx.SetTaborder('qty', ll_i)
  164. ll_i += ll_step
  165. dw_mx.SetTaborder('requiredate', ll_i)
  166. ll_i += ll_step
  167. dw_mx.SetTaborder('mxdscrp', ll_i)
  168. ll_i += ll_step
  169. dw_mx.SetTaborder('mxdscrp2', ll_i)
  170. end subroutine
  171. private subroutine wf_face ();if (if_modify_mode) then
  172. cb_addmx.Visible = true
  173. cb_addmx.Enabled = true
  174. cb_delmx.Visible = true
  175. cb_delmx.Enabled = true
  176. else
  177. cb_addmx.Visible = false
  178. cb_addmx.Enabled = false
  179. cb_delmx.Visible = false
  180. cb_delmx.Enabled = false
  181. end if
  182. if (ins_tran.taskid <= 0) then
  183. cb_func.Text = '新建'
  184. cb_func.normalpicname = 'new.bmp'
  185. elseif (ins_tran.status = 0) then
  186. cb_func.Text = '退回'
  187. cb_func.normalpicname = 'Undo.bmp'
  188. elseif (ins_tran.status = 2) then
  189. cb_func.Text = '重建'
  190. cb_func.normalpicname = 'new.bmp'
  191. elseif (ins_tran.status = 4) then // 待付款[4]
  192. cb_func.Text = '审核'
  193. cb_func.normalpicname = 'audit.bmp'
  194. elseif (ins_tran.status = 8) then // 已发货[8]
  195. cb_func.Text = '收货'
  196. cb_func.normalpicname = 'audit.bmp'
  197. else
  198. cb_func.Visible = false
  199. cb_func.Enabled = false
  200. end if
  201. cb_func.of_init_draw()
  202. cb_func.of_paint()
  203. cb_func.TriggerEvent('ue_textchange')
  204. end subroutine
  205. public function integer wf_save (s_fx_saletask a_tran, ref string arg_msg);// 新建/退回订单保存
  206. int rslt = 1
  207. arg_msg = ''
  208. if (IsNull(a_tran.cus_rep)) then a_tran.cus_rep = ''
  209. if (IsNull(a_tran.cus_tele)) then a_tran.cus_tele = ''
  210. if (IsNull(a_tran.cus_address)) then a_tran.cus_address = ''
  211. if (IsNull(a_tran.temp1)) then a_tran.temp1 = ''
  212. if (IsNull(a_tran.temp2)) then a_tran.temp2 = ''
  213. if (IsNull(a_tran.temp3)) then a_tran.temp3 = ''
  214. if (a_tran.cus_rep = '' &
  215. or a_tran.cus_rep = '' &
  216. or a_tran.cus_rep = '') then
  217. rslt = 0
  218. arg_msg = '收货人/联系电话/收货地址不能为空'
  219. goto ext
  220. end if
  221. long ll_i
  222. if (IsNull(a_tran.mx)) then
  223. rslt = 0
  224. arg_msg = '没有订单明细(null)'
  225. goto ext
  226. end if
  227. if (UpperBound(a_tran.mx) <= 0) then
  228. rslt = 0
  229. arg_msg = '没有订单明细(0)'
  230. goto ext
  231. end if
  232. for ll_i = 1 to UpperBound(a_tran.mx)
  233. if (a_tran.mx[ll_i].qty <= 0) then
  234. rslt = 0
  235. arg_msg += '明细行:' + string(ll_i) + '数量有误;~r~n'
  236. end if
  237. next
  238. if (rslt <> 1) then goto ext
  239. // 1-先上传新增附件的md5,与服务器对比,2-返回服务器没有的md5,再上传附件数据
  240. long ll_index = 0
  241. string ls_arr_1_md5[], ls_arr_1_filepath[]
  242. if (not IsNull(a_tran.fj)) then
  243. for ll_i = 1 to UpperBound(a_tran.fj)
  244. if (a_tran.fj[ll_i].fjprintid <= 0) then
  245. ll_index++
  246. ls_arr_1_md5[ll_index] = a_tran.fj[ll_i].filemd5
  247. ls_arr_1_filepath[ll_index] = a_tran.fj[ll_i].filepath
  248. end if
  249. next
  250. end if
  251. if (UpperBound(ls_arr_1_md5) > 0) then
  252. if (f_chkfxfilemapwithmd5andupload(ls_arr_1_md5, ls_arr_1_filepath, ref arg_msg) <> 1) then
  253. rslt = 0
  254. goto ext
  255. end if
  256. end if
  257. // 保存订单
  258. oleobject req, rsp
  259. oleobject taskinfo, items, fjs, item
  260. oleobject mtrlitem
  261. // 主表
  262. taskinfo = FXAppCom.CreatePbDictionary()
  263. taskinfo.SetInt('taskid', a_tran.taskid)
  264. taskinfo.SetInt('billtype', a_tran.billtype)
  265. taskinfo.SetString('cus_rep', a_tran.cus_rep)
  266. taskinfo.SetString('cus_tele', a_tran.cus_tele)
  267. taskinfo.SetString('cus_address', a_tran.cus_address)
  268. taskinfo.SetString('temp1', a_tran.temp1)
  269. taskinfo.SetString('temp2', a_tran.temp2)
  270. taskinfo.SetString('temp3', a_tran.temp3)
  271. // 订单明细
  272. items = FXAppCom.NewPBArray()
  273. for ll_i = 1 to UpperBound(a_tran.mx)
  274. item = FXAppCom.CreatePbDictionary()
  275. item.SetInt('printid', a_tran.mx[ll_i].printid)
  276. item.SetDouble('num', a_tran.mx[ll_i].qty)
  277. item.SetInt('cartitemid', 0)
  278. item.SetString('status', '')
  279. item.SetString('woodcode', '')
  280. item.SetString('pcode', '')
  281. item.SetString('mxdscrp', a_tran.mx[ll_i].mxdscrp)
  282. item.SetString('mxdscrp2', a_tran.mx[ll_i].mxdscrp2)
  283. //mtrlitem
  284. mtrlitem = FXAppCom.CreatePbDictionary()
  285. mtrlitem.SetInt('fxmtrlid', a_tran.mx[ll_i].fxmtrlid)
  286. mtrlitem.SetInt('fxmtrlid_ori', a_tran.mx[ll_i].fxmtrlid_ori)
  287. mtrlitem.SetInt('mtrlid_ori', a_tran.mx[ll_i].mtrlid_ori)
  288. mtrlitem.SetInt('mtrlid_erp', a_tran.mx[ll_i].mtrlid)
  289. mtrlitem.SetDateTime('requiredate', a_tran.mx[ll_i].requiredate)
  290. item.SetObject('mtrlitem', mtrlitem)
  291. items.AddObject(item)
  292. next
  293. // 订单附件
  294. fjs = FXAppCom.NewPBArray()
  295. for ll_i = 1 to UpperBound(a_tran.fj)
  296. item = FXAppCom.CreatePbDictionary()
  297. item.SetInt('fjprintid', a_tran.fj[ll_i].fjprintid)
  298. item.SetInt('mxprintid', a_tran.fj[ll_i].mxprintid)
  299. item.SetInt('fjType', a_tran.fj[ll_i].fjType)
  300. item.SetString('dscrp', a_tran.fj[ll_i].dscrp)
  301. item.SetString('fileName', a_tran.fj[ll_i].fileName)
  302. item.SetString('fileType', a_tran.fj[ll_i].fileType)
  303. item.SetString('filemd5', a_tran.fj[ll_i].filemd5)
  304. //item.SetString('filepath', a_tran.fj[ll_i].filepath)
  305. fjs.AddObject(item)
  306. next
  307. // 提交
  308. req = FXAppCom.CreatePbDictionary()
  309. req.SetString('token', app_token_fx)
  310. req.SetObject('taskinfo', taskinfo)
  311. req.SetObject('items', items)
  312. req.SetObject('fjs', fjs)
  313. rsp = FXAppCom.DoExecute('SaveTask', req)
  314. arg_msg = rsp.GetString('ErrMsg')
  315. if (arg_msg <> '') then
  316. rslt = 0
  317. goto ext
  318. end if
  319. ext:
  320. return rslt
  321. end function
  322. private subroutine wf_add_saletask (long a_mode);// 新建/查看退回订单
  323. // a_mode 0-新建 1-查看/退回
  324. dw_main.Reset()
  325. long ll_insertRow
  326. ll_insertRow = dw_main.InsertRow(0)
  327. if (a_mode = 0) then // 新建
  328. dw_main.Object.status[ll_insertRow] = 0
  329. dw_main.Object.cus_rep[ll_insertRow] = ''
  330. dw_main.Object.cus_tele[ll_insertRow] = ''
  331. dw_main.Object.cus_address[ll_insertRow] = ''
  332. dw_main.Object.temp1[ll_insertRow] = ''
  333. dw_main.Object.temp2[ll_insertRow] = ''
  334. dw_main.Object.temp3[ll_insertRow] = ''
  335. dw_main.Object.opemp[ll_insertRow] = app_username
  336. dw_main.Object.opdate[ll_insertRow] = DateTime(Today(), Now())
  337. else // 查看/退回
  338. dw_main.Object.gpCode[ll_insertRow] = ins_tran.gpCode
  339. dw_main.Object.tid[ll_insertRow] = ins_tran.tid
  340. dw_main.Object.status[ll_insertRow] = ins_tran.status
  341. dw_main.Object.cus_rep[ll_insertRow] = ins_tran.cus_rep
  342. dw_main.Object.cus_tele[ll_insertRow] = ins_tran.cus_tele
  343. dw_main.Object.cus_address[ll_insertRow] = ins_tran.cus_address
  344. dw_main.Object.temp1[ll_insertRow] = ins_tran.temp1
  345. dw_main.Object.temp2[ll_insertRow] = ins_tran.temp2
  346. dw_main.Object.temp3[ll_insertRow] = ins_tran.temp3
  347. dw_main.Object.opemp[ll_insertRow] = ins_tran.opemp
  348. dw_main.Object.opdate[ll_insertRow] = ins_tran.opdate
  349. dw_main.Object.modemp[ll_insertRow] = ins_tran.modemp
  350. dw_main.Object.moddate[ll_insertRow] = ins_tran.moddate
  351. dw_main.Object.erpstatus[ll_insertRow] = ins_tran.erpstatus
  352. dw_main.Object.freight[ll_insertRow] = ins_tran.freight
  353. dw_main.Object.freight_tele[ll_insertRow] = ins_tran.freight_tele
  354. dw_main.Object.replyrqdate[ll_insertRow] = ins_tran.replyrqdate
  355. dw_main.Object.addCost[ll_insertRow] = ins_tran.addCost
  356. dw_main.Object.erpConfirmEmp[ll_insertRow] = ins_tran.erpConfirmEmp
  357. dw_main.Object.erpConfirmDate[ll_insertRow] = ins_tran.erpConfirmDate
  358. dw_main.Object.splitEmp[ll_insertRow] = ins_tran.splitEmp
  359. dw_main.Object.splitDate[ll_insertRow] = ins_tran.splitDate
  360. dw_main.Object.splitConfirmEmp[ll_insertRow] = ins_tran.splitConfirmEmp
  361. dw_main.Object.splitConfirmDate[ll_insertRow] = ins_tran.splitConfirmDate
  362. dw_main.Object.price_emp[ll_insertRow] = ins_tran.price_emp
  363. dw_main.Object.priceDate[ll_insertRow] = ins_tran.priceDate
  364. dw_main.Object.priceConfirmEmp[ll_insertRow] = ins_tran.priceConfirmEmp
  365. dw_main.Object.priceConfirmDate[ll_insertRow] = ins_tran.priceConfirmDate
  366. dw_main.Object.payConfirmEmp[ll_insertRow] = ins_tran.payConfirmEmp
  367. dw_main.Object.payConfirmDate[ll_insertRow] = ins_tran.payConfirmDate
  368. dw_main.Object.taskid[ll_insertRow] = ins_tran.taskid
  369. dw_main.Object.sptcomid[ll_insertRow] = ins_tran.sptcomid
  370. dw_main.Object.cuscomid[ll_insertRow] = ins_tran.cuscomid
  371. dw_main.Object.buyer_name[ll_insertRow] = ins_tran.buyer_name
  372. dw_main.Object.buyer_tele[ll_insertRow] = ins_tran.buyer_tele
  373. // dw_main.Object.temp4[ll_insertRow] = ins_tran.temp4
  374. // dw_main.Object.temp5[ll_insertRow] = ins_tran.temp5
  375. // dw_main.Object.temp6[ll_insertRow] = ins_tran.temp6
  376. // dw_main.Object.replydscrp[ll_insertRow] = ins_tran.replydscrp
  377. // dw_main.Object.replydate[ll_insertRow] = ins_tran.replydate
  378. // dw_main.Object.confirmemp[ll_insertRow] = ins_tran.confirmemp
  379. // dw_main.Object.confirmdate[ll_insertRow] = ins_tran.confirmdate
  380. // dw_main.Object.outwarecode[ll_insertRow] = ins_tran.outwarecode
  381. // dw_main.Object.fstatus[ll_insertRow] = ins_tran.fstatus
  382. dw_main.Object.billtype[ll_insertRow] = ins_tran.billtype
  383. dw_main.Object.taskdate[ll_insertRow] = ins_tran.taskdate
  384. dw_main.Object.taskcode[ll_insertRow] = ins_tran.taskcode
  385. dw_main.Object.requiredate[ll_insertRow] = ins_tran.requiredate
  386. dw_main.Object.addressid[ll_insertRow] = 0
  387. end if
  388. dw_main.AcceptText()
  389. end subroutine
  390. public subroutine wf_add_saletaskmx ();// 获取订单明细
  391. dw_mx.Reset()
  392. string arg_msg
  393. oleobject req, rsp
  394. req = FXAppCom.CreatePbDictionary()
  395. req.SetString('token', app_token_fx)
  396. req.SetInt('taskid', ins_tran.taskid)
  397. rsp = FXAppCom.DoExecute('GetBuytaskmx', req)
  398. arg_msg = rsp.GetString('ErrMsg')
  399. if (arg_msg <> '') then
  400. MessageBox('提示', arg_msg)
  401. return
  402. end if
  403. oleobject item, list
  404. list = rsp.GetPBArray('mxs')
  405. long ll_i, ll_insertRow
  406. for ll_i = 1 to list.Count
  407. item = list.GetPBDictionary(ll_i - 1)
  408. ll_insertRow = dw_mx.InsertRow(0)
  409. dw_mx.Object.printid[ll_insertRow] = item.GetInt('printid')
  410. dw_mx.Object.mb_mtrlcode[ll_insertRow] = item.GetString('mb_mtrlcode')
  411. dw_mx.Object.mb_mtrlname[ll_insertRow] = item.GetString('mb_mtrlname')
  412. dw_mx.Object.mb_mtrlmode[ll_insertRow] = item.GetString('mb_mtrlmode')
  413. dw_mx.Object.qty[ll_insertRow] = item.GetDouble('qty')
  414. if (not IsNull(item.GetDateTime('requiredate'))) then
  415. dw_mx.Object.requiredate[ll_insertRow] = item.GetDateTime('requiredate')
  416. end if
  417. dw_mx.Object.mxdscrp[ll_insertRow] = item.GetString('mxdscrp')
  418. dw_mx.Object.mxdscrp2[ll_insertRow] = item.GetString('mxdscrp2')
  419. dw_mx.Object.price[ll_insertRow] = item.GetDouble('price')
  420. dw_mx.Object.mtrlcode[ll_insertRow] = item.GetString('mtrlcode')
  421. dw_mx.Object.mtrlname[ll_insertRow] = item.GetString('mtrlname')
  422. dw_mx.Object.mtrlmode[ll_insertRow] = item.GetString('mtrlmode')
  423. dw_mx.Object.plancode[ll_insertRow] = item.GetString('plancode')
  424. dw_mx.Object.mtrlcuscode[ll_insertRow] = item.GetString('mtrlcuscode')
  425. dw_mx.Object.cus_receiveqty[ll_insertRow] = item.GetDouble('cus_receiveqty')
  426. dw_mx.Object.qty_ready[ll_insertRow] = item.GetDouble('qty_ready')
  427. dw_mx.Object.outQty[ll_insertRow] = item.GetDouble('outQty')
  428. if (not IsNull(item.GetDateTime('outDate'))) then
  429. dw_mx.Object.outDate[ll_insertRow] = item.GetDateTime('outDate')
  430. end if
  431. dw_mx.Object.stopQty[ll_insertRow] = item.GetDouble('stopQty')
  432. dw_mx.Object.stopEmp[ll_insertRow] = item.GetString('stopEmp')
  433. if (not IsNull(item.GetDateTime('stopDate'))) then
  434. dw_mx.Object.stopDate[ll_insertRow] = item.GetDateTime('stopDate')
  435. end if
  436. dw_mx.Object.stopReason[ll_insertRow] = item.GetString('stopReason')
  437. dw_mx.Object.status[ll_insertRow] = item.GetString('status')
  438. dw_mx.Object.woodcode[ll_insertRow] = item.GetString('woodcode')
  439. dw_mx.Object.pcode[ll_insertRow] = item.GetString('pcode')
  440. if (not IsNull(item.GetDateTime('qty_ready_opdate'))) then
  441. dw_mx.Object.qty_ready_opdate[ll_insertRow] = item.GetDateTime('qty_ready_opdate')
  442. end if
  443. dw_mx.Object.taskid[ll_insertRow] = item.GetInt('taskid')
  444. dw_mx.Object.mxcode[ll_insertRow] = item.GetString('mxcode')
  445. dw_mx.Object.mtrlid[ll_insertRow] = item.GetInt('mtrlid')
  446. dw_mx.Object.fxmtrlid[ll_insertRow] = item.GetInt('fxmtrlid')
  447. dw_mx.Object.qty_ready_userid[ll_insertRow] = item.GetInt('qty_ready_userid')
  448. dw_mx.Object.fxmtrlid_ori[ll_insertRow] = item.GetInt('fxmtrlid_ori')
  449. dw_mx.Object.mtrlid_ori[ll_insertRow] = item.GetInt('mtrlid_ori')
  450. next
  451. end subroutine
  452. public function integer wf_cancel (string a_reason, ref string arg_msg);// 取消(退回)订单
  453. int rslt = 1
  454. arg_msg = ''
  455. if (IsNull(a_reason)) then a_reason = ''
  456. if (a_reason = '') then
  457. rslt = 0
  458. arg_msg = '订单取消原因不能为空'
  459. goto ext
  460. end if
  461. oleobject req, rsp
  462. req = FXAppCom.CreatePbDictionary()
  463. req.SetString('token', app_token_fx)
  464. req.SetInt('taskid', ins_tran.taskid)
  465. req.SetString('reason', a_reason)
  466. rsp = FXAppCom.DoExecute('CancelTask', req)
  467. arg_msg = rsp.GetString('ErrMsg')
  468. if (arg_msg <> '') then
  469. rslt = 0
  470. goto ext
  471. end if
  472. ext:
  473. return rslt
  474. end function
  475. on w_buytask_custom_view_fx.create
  476. int iCurrent
  477. call super::create
  478. this.cb_addmx=create cb_addmx
  479. this.cb_delmx=create cb_delmx
  480. this.uo_tab=create uo_tab
  481. this.dw_main=create dw_main
  482. this.dw_mx=create dw_mx
  483. iCurrent=UpperBound(this.Control)
  484. this.Control[iCurrent+1]=this.cb_addmx
  485. this.Control[iCurrent+2]=this.cb_delmx
  486. this.Control[iCurrent+3]=this.uo_tab
  487. this.Control[iCurrent+4]=this.dw_main
  488. this.Control[iCurrent+5]=this.dw_mx
  489. end on
  490. on w_buytask_custom_view_fx.destroy
  491. call super::destroy
  492. destroy(this.cb_addmx)
  493. destroy(this.cb_delmx)
  494. destroy(this.uo_tab)
  495. destroy(this.dw_main)
  496. destroy(this.dw_mx)
  497. end on
  498. event open;call super::open;ins_tran = Message.PowerObjectParm
  499. if (IsNull(ins_tran)) then
  500. Close(this)
  501. return
  502. end if
  503. if (not IsValid(ins_tran)) then
  504. Close(this)
  505. return
  506. end if
  507. if ((ins_tran.taskid <= 0 and ins_tran.status = 0) or (ins_tran.status = 2)) then // 编辑状态
  508. if_modify_mode = true
  509. dw_main.DataObject = 'dw_fx_buytask_custom_new'
  510. if (ins_tran.taskid <= 0) then // 新建
  511. wf_add_saletask(0)
  512. else // 退回
  513. wf_add_saletask(1)
  514. wf_add_saletaskmx()
  515. end if
  516. else
  517. if_modify_mode = false
  518. dw_main.DataObject = 'dw_fx_buytask_custom_view'
  519. wf_add_saletask(1)
  520. wf_add_saletaskmx()
  521. end if
  522. uo_tab.post event ue_init_with_tid(ins_tran.taskid, ins_tran.status, ins_tran.tid, this)
  523. wf_face()
  524. wf_taborder()
  525. this.post event resize(0, 0, 0)
  526. end event
  527. event resize;call super::resize;dw_main.Width = this.workspacewidth()
  528. dw_mx.Width = this.workspacewidth()
  529. uo_tab.Width = this.workspacewidth()
  530. if (if_modify_mode) then
  531. dw_main.Height = 724
  532. dw_mx.Y = cb_addmx.Y + 100
  533. dw_mx.Height = 600
  534. else
  535. dw_main.Height = 1088
  536. dw_mx.Y = dw_main.Y + dw_main.Height + 2
  537. dw_mx.Height = 360
  538. end if
  539. uo_tab.Y = dw_mx.Y + dw_mx.Height + 10
  540. uo_tab.Height = this.workspaceheight() - uo_tab.Y - 160
  541. uo_tab.post event ue_resize()
  542. end event
  543. event close;call super::close;CloseWithReturn(this, ins_ret)
  544. end event
  545. type cb_func from w_publ_base`cb_func within w_buytask_custom_view_fx
  546. integer x = 2999
  547. integer y = 2596
  548. integer taborder = 60
  549. string normalpicname = "new.bmp"
  550. integer picsize = 16
  551. end type
  552. event cb_func::clicked;call super::clicked;s_fx_saletask s_main
  553. s_fx_saletaskmx s_mx, s_empty_mx
  554. s_fx_saletask_fj s_fj, s_empty_fj
  555. s_inputbox s_input
  556. string ls_ret
  557. long ll_row, ll_i
  558. string arg_msg
  559. if ((ins_tran.taskid <= 0 and ins_tran.status = 0) or (ins_tran.status = 2)) then // 新建/重新下单
  560. dw_main.AcceptText()
  561. dw_mx.SetFilter('')
  562. dw_mx.Filter()
  563. dw_mx.AcceptText()
  564. uo_tab.tabpage_fj.dw_fj.SetFilter('')
  565. uo_tab.tabpage_fj.dw_fj.Filter()
  566. uo_tab.tabpage_fj.dw_fj.AcceptText()
  567. ll_row = dw_main.GetRow()
  568. if (ll_row <= 0) then
  569. MessageBox('提示', '获取当前单据信息失败,请联系开发人员')
  570. return
  571. end if
  572. s_main.taskid = ins_tran.taskid
  573. s_main.billtype = 1 // 定制产品订单
  574. s_main.cus_rep = Trim(dw_main.Object.cus_rep[ll_row])
  575. s_main.cus_tele = Trim(dw_main.Object.cus_tele[ll_row])
  576. s_main.cus_address = Trim(dw_main.Object.cus_address[ll_row])
  577. s_main.temp1 = Trim(dw_main.Object.temp1[ll_row])
  578. s_main.temp2 = Trim(dw_main.Object.temp2[ll_row])
  579. s_main.temp3 = Trim(dw_main.Object.temp3[ll_row])
  580. if (dw_mx.RowCount() <= 0) then
  581. MessageBox('提示', '没有订单明细')
  582. return
  583. end if
  584. for ll_i = 1 to dw_mx.RowCount()
  585. s_mx = s_empty_mx
  586. s_mx.printid = dw_mx.Object.printid[ll_i]
  587. s_mx.qty = dw_mx.Object.qty[ll_i]
  588. s_mx.requiredate = dw_mx.Object.requiredate[ll_i]
  589. s_mx.fxmtrlid_ori = dw_mx.Object.fxmtrlid_ori[ll_i]
  590. s_mx.fxmtrlid = dw_mx.Object.fxmtrlid[ll_i]
  591. s_mx.mtrlid_ori = dw_mx.Object.mtrlid_ori[ll_i]
  592. s_mx.mtrlid = dw_mx.Object.mtrlid[ll_i]
  593. s_mx.mxdscrp = Trim(dw_mx.Object.mxdscrp[ll_i])
  594. s_mx.mxdscrp2 = Trim(dw_mx.Object.mxdscrp2[ll_i])
  595. // s_mx.status = dw_mx.Object.status[ll_i]
  596. // s_mx.woodcode = dw_mx.Object.woodcode[ll_i]
  597. // s_mx.pcode = dw_mx.Object.pcode[ll_i]
  598. s_main.mx[ll_i] = s_mx
  599. next
  600. for ll_i = 1 to uo_tab.tabpage_fj.dw_fj.RowCount()
  601. s_fj = s_empty_fj
  602. s_fj.fjprintid = uo_tab.tabpage_fj.dw_fj.Object.fjprintid[ll_i]
  603. s_fj.mxprintid = uo_tab.tabpage_fj.dw_fj.Object.mxprintid[ll_i]
  604. s_fj.fjType = uo_tab.tabpage_fj.dw_fj.Object.fjType[ll_i]
  605. s_fj.dscrp = Trim(uo_tab.tabpage_fj.dw_fj.Object.dscrp[ll_i])
  606. s_fj.fileName = uo_tab.tabpage_fj.dw_fj.Object.fileName[ll_i]
  607. s_fj.fileType = uo_tab.tabpage_fj.dw_fj.Object.fileType[ll_i]
  608. s_fj.filemd5 = uo_tab.tabpage_fj.dw_fj.Object.filemd5[ll_i]
  609. s_fj.filepath = uo_tab.tabpage_fj.dw_fj.Object.filepath[ll_i]
  610. s_main.fj[ll_i] = s_fj
  611. next
  612. if (wf_save(s_main, ref arg_msg) <> 1) then
  613. MessageBox('提示', '订单保存失败:' + arg_msg)
  614. else
  615. ins_ret = 1
  616. MessageBox('提示', '订单保存成功')
  617. Close(parent)
  618. end if
  619. elseif (ins_tran.taskid > 0 and ins_tran.status = 0) then // 退回
  620. s_input.title = '取消原因'
  621. s_input.old_text = '退回订单'
  622. OpenWithParm(w_inputbox, s_input)
  623. ls_ret = Message.StringParm
  624. if (ls_ret = '') then
  625. MessageBox('提示', '请填写退回原因')
  626. return
  627. end if
  628. if (MessageBox('提示', '确认退回当前订单?', Question!, YesNo!) <> 1) then return
  629. if (wf_cancel(ls_ret, ref arg_msg) <> 1) then
  630. MessageBox('提示', '订单退回失败:' + arg_msg)
  631. else
  632. ins_ret = 1
  633. MessageBox('提示', '订单退回成功')
  634. Close(parent)
  635. end if
  636. elseif (ins_tran.status = 4) then // 审核
  637. // TODO:检查付款凭证
  638. //wf_audit()
  639. elseif (ins_tran.status = 8) then // 收货
  640. end if
  641. end event
  642. type cb_exit from w_publ_base`cb_exit within w_buytask_custom_view_fx
  643. integer x = 3314
  644. integer y = 2596
  645. integer taborder = 70
  646. end type
  647. type cb_addmx from commandbutton within w_buytask_custom_view_fx
  648. integer x = 23
  649. integer y = 744
  650. integer width = 288
  651. integer height = 80
  652. integer taborder = 20
  653. boolean bringtotop = true
  654. integer textsize = -9
  655. integer weight = 400
  656. fontcharset fontcharset = gb2312charset!
  657. fontpitch fontpitch = variable!
  658. string facename = "宋体"
  659. string text = "添加"
  660. end type
  661. event clicked;wf_add_mx()
  662. end event
  663. type cb_delmx from commandbutton within w_buytask_custom_view_fx
  664. integer x = 325
  665. integer y = 744
  666. integer width = 288
  667. integer height = 80
  668. integer taborder = 30
  669. boolean bringtotop = true
  670. integer textsize = -9
  671. integer weight = 400
  672. fontcharset fontcharset = gb2312charset!
  673. fontpitch fontpitch = variable!
  674. string facename = "宋体"
  675. string text = "删除"
  676. end type
  677. event clicked;if (not if_modify_mode) then return
  678. long ll_row, ll_printid
  679. ll_row = dw_mx.GetRow()
  680. if (ll_row <= 0) then
  681. Messagebox('提示', '请选择需要删除的明细行')
  682. return
  683. end if
  684. ll_printid = dw_mx.Object.printid[ll_row]
  685. dw_mx.DeleteRow(ll_row)
  686. // 删除相应的附件
  687. uo_tab.post event ue_tab_fj_del(ll_printid)
  688. if (dw_mx.RowCount() > 0 and ll_row <= dw_mx.RowCount()) then
  689. dw_mx.SetRow(ll_row)
  690. dw_mx.SelectRow(0, false)
  691. dw_mx.SelectRow(ll_row, true)
  692. end if
  693. end event
  694. type uo_tab from uo_fx_saletask_custom_tab within w_buytask_custom_view_fx
  695. integer y = 1456
  696. integer width = 3653
  697. integer height = 1116
  698. integer taborder = 50
  699. boolean bringtotop = true
  700. end type
  701. type dw_main from datawindow within w_buytask_custom_view_fx
  702. integer width = 3657
  703. integer height = 724
  704. integer taborder = 10
  705. boolean bringtotop = true
  706. string title = "none"
  707. string dataobject = "dw_fx_buytask_custom_new"
  708. boolean livescroll = true
  709. end type
  710. event clicked;if (if_modify_mode) then
  711. if (dwo.Name = 'b_cus') then // 收货人地址管理
  712. wf_address_ch()
  713. end if
  714. end if
  715. end event
  716. event doubleclicked;if (if_modify_mode) then
  717. if (dwo.Name = 'cus_rep' &
  718. or dwo.Name = 'cus_tele' &
  719. or dwo.Name = 'cus_address') then // 收货人地址管理
  720. wf_address_ch()
  721. end if
  722. end if
  723. end event
  724. type dw_mx from u_dw_rbtnfilter within w_buytask_custom_view_fx
  725. integer y = 844
  726. integer width = 3657
  727. integer height = 360
  728. integer taborder = 40
  729. boolean bringtotop = true
  730. string dataobject = "dw_fx_buytaskmx_custom"
  731. boolean hscrollbar = true
  732. boolean vscrollbar = true
  733. boolean hsplitscroll = true
  734. borderstyle borderstyle = stylebox!
  735. boolean rbutton_filter_use = true
  736. boolean rbutton_setposition_use = true
  737. boolean titleclick_sort_use = true
  738. end type
  739. event doubleclicked;call super::doubleclicked;if (if_modify_mode and dwo.Type = 'datawindow') then
  740. wf_add_mx()
  741. end if
  742. end event
  743. event clicked;call super::clicked;if (row > 0) then
  744. this.SetRow(row)
  745. this.SelectRow(0, false)
  746. this.SelectRow(row, true)
  747. end if
  748. end event
  749. event rowfocuschanged;call super::rowfocuschanged;if (currentrow > 0) then
  750. this.SetRow(currentrow)
  751. this.SelectRow(0, false)
  752. this.SelectRow(currentrow, true)
  753. end if
  754. end event