MaterialStocktaking.qml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. import QtQuick
  2. import QtQuick.Controls
  3. import QtQuick.Layouts
  4. // 物资盘点界面
  5. Item {
  6. id: materialstocktaking_item_root
  7. x: 290
  8. y: 130
  9. width: 1600
  10. height: 920
  11. onVisibleChanged: {
  12. proThread.moveCursorTo(0, 0);
  13. }
  14. ListModel {
  15. id: materialstocktaking_model_dissolve
  16. }
  17. ListModel {
  18. id: materialstocktaking_model_misplace
  19. }
  20. ListModel {
  21. id: materialstocktaking_model_binded
  22. }
  23. ListModel {
  24. id: materialstocktaking_model_unbind
  25. }
  26. ListModel {
  27. id: materialstocktaking_model_take
  28. }
  29. ListModel {
  30. id: materialstocktaking_model_back
  31. }
  32. Rectangle {
  33. width: 1600
  34. height: 800
  35. color: "#272b7ae9"
  36. radius: 20
  37. clip: true
  38. Rectangle {
  39. width: 1600
  40. height: 100 // 减去顶部圆角矩形的高度
  41. radius: 20
  42. clip: true
  43. color: "#8f2b7ae9"
  44. Text {
  45. id: materialstocktaking_text_title;
  46. x: 50
  47. y: 25
  48. width: 500
  49. height: 50
  50. visible: true
  51. text: "本次物资取还记录如下:"
  52. font.pixelSize: 30
  53. horizontalAlignment: Text.AlignLeft
  54. verticalAlignment: Text.AlignVCenter
  55. font.bold: true
  56. color: "#ffffff"
  57. }
  58. }
  59. Flickable {
  60. x: 0
  61. y: 100
  62. width: 1600
  63. height: 700
  64. contentWidth: 1600 // 内容宽度
  65. contentHeight: materialstocktaking_column.height // 内容高度
  66. clip: true // 裁剪超出部分
  67. Column {
  68. id: materialstocktaking_column
  69. width: parent.width
  70. spacing: 0
  71. padding: 0
  72. ReuseMaterialList {
  73. id: materialstocktaking_list_unchanged
  74. _color: "#ffffff"
  75. _title: "没有物资数据发生变化"
  76. _line: false;
  77. _date: false;
  78. _name: false;
  79. }
  80. ReuseMaterialList {
  81. id: materialstocktaking_list_dissolve
  82. _color: "#00ff00"
  83. _title: "拿出了不属于该柜子的物资:"
  84. _model: materialstocktaking_model_dissolve
  85. }
  86. ReuseMaterialList {
  87. id: materialstocktaking_list_misplace
  88. _color: "#ff0000"
  89. _title: "放入了不属于该柜子的物资:"
  90. _model: materialstocktaking_model_misplace
  91. }
  92. ReuseMaterialList {
  93. id: materialstocktaking_list_binded
  94. _color: "#ffffff"
  95. _title: "新放入以下物资:"
  96. _model: materialstocktaking_model_binded
  97. }
  98. ReuseMaterialList {
  99. id: materialstocktaking_list_unbind
  100. _color: "#ffffff"
  101. _title: "替换以下物资:"
  102. _model: materialstocktaking_model_unbind
  103. }
  104. ReuseMaterialList {
  105. id: materialstocktaking_list_take
  106. _color: "#ffffff"
  107. _title: "领取以下物资:"
  108. _model: materialstocktaking_model_take
  109. }
  110. ReuseMaterialList {
  111. id: materialstocktaking_list_back
  112. _color: "#ffffff"
  113. _title: "归还以下物资:"
  114. _model: materialstocktaking_model_back
  115. }
  116. }
  117. }
  118. }
  119. // 声明自定义组件
  120. QtObject {
  121. id: materialstocktaking_object
  122. // 自定义物资项
  123. component ReuseMaterialItem: Rectangle {
  124. width: 250
  125. height: 300
  126. color: "#00ffffff"
  127. Rectangle {
  128. x: 25
  129. y: 0
  130. width: 200
  131. height: 200
  132. color: "#00ffffff"
  133. Image {
  134. anchors.fill: parent
  135. visible: true
  136. source: model.png
  137. fillMode: Image.PreserveAspectFit
  138. }
  139. }
  140. Text {
  141. x: 0
  142. y: 200
  143. width: parent.width
  144. height: 50
  145. visible: true
  146. text: model.name
  147. font.pixelSize: 30
  148. horizontalAlignment: Text.AlignHCenter
  149. verticalAlignment: Text.AlignVCenter
  150. color: "#ffffff"
  151. }
  152. Text {
  153. x: 0
  154. y: 250
  155. width: parent.width
  156. height: 25
  157. visible: true
  158. text: model.rfid
  159. font.pixelSize: 12
  160. horizontalAlignment: Text.AlignHCenter
  161. verticalAlignment: Text.AlignVCenter
  162. color: "#ffffff"
  163. }
  164. }
  165. // 自定义物资列表
  166. component ReuseMaterialList: Rectangle {
  167. property var _color;
  168. property var _model;
  169. property var _title;
  170. property bool _line: true;
  171. property bool _date: true;
  172. property bool _name: true;
  173. width: 1600
  174. height: 350
  175. color: "#00ffffff"
  176. // border.color: _color
  177. // border.width: 2
  178. Text {
  179. x: 50
  180. y: 0
  181. width: 260
  182. height: 50
  183. visible: true
  184. text: backDatetime
  185. font.pixelSize: 25
  186. horizontalAlignment: Text.AlignLeft
  187. verticalAlignment: Text.AlignVCenter
  188. font.bold: true
  189. color: _date ? "#ffffff" : "#00ffffff"
  190. }
  191. Text {
  192. x: 310
  193. y: 0
  194. width: 120
  195. height: 50
  196. visible: true
  197. text: backName
  198. font.pixelSize: 25
  199. horizontalAlignment: Text.AlignHCenter
  200. verticalAlignment: Text.AlignVCenter
  201. font.underline: true
  202. font.bold: true
  203. color: _name ? "#ffffff" : "#00ffffff"
  204. }
  205. Text {
  206. x: (_date || _name) ? 430 : 50
  207. y: 0
  208. width: 1600 - 25
  209. height: 50
  210. visible: true
  211. text: _title
  212. font.pixelSize: 25
  213. horizontalAlignment: Text.AlignLeft
  214. verticalAlignment: Text.AlignVCenter
  215. font.bold: true
  216. color: _color
  217. }
  218. ListView {
  219. x: 25
  220. y: 50
  221. width: parent.width - 50
  222. height: parent.height - 50
  223. // spacing: 10 // 间隔
  224. orientation: ListView.Horizontal // 横向滚动
  225. model: _model
  226. delegate: ReuseMaterialItem {
  227. }
  228. }
  229. // 绘制底部线条
  230. Canvas {
  231. anchors.fill: parent
  232. visible: _line;
  233. onPaint: {
  234. var ctx = getContext("2d");
  235. ctx.lineWidth = 5;
  236. ctx.strokeStyle = "skyblue";
  237. ctx.beginPath();
  238. ctx.moveTo(5, (parent.height));
  239. ctx.lineTo(parent.width - 5, parent.height);
  240. ctx.stroke();
  241. }
  242. }
  243. }
  244. }
  245. property string takeDatetime : "2025-03-02 13:16:25"
  246. property string takeName : "张天乐"
  247. property string backDatetime : "2025-03-02 13:16:25"
  248. property string backName : "张天乐"
  249. property bool takestock : true
  250. property string takestocknotice : "物资盘点中,请耐心等待......"
  251. property int takestockviewcount : 1
  252. property int stockcountdown : 5
  253. property string stockcountdownstr : "倒计时:99秒"
  254. Button {
  255. id: materialstocktaking_button_return
  256. x: 1408
  257. y: 835
  258. width: 192
  259. height: 75
  260. background: Rectangle {
  261. color: "#055eb3" // 设置背景为透明
  262. radius: 10 // 可选,设置圆角
  263. }
  264. text: qsTr("确定")
  265. font.pixelSize: 30
  266. palette.buttonText: "white" // 设置字体颜色为绿色
  267. Connections {
  268. target: materialstocktaking_button_return
  269. onClicked: {
  270. materialstocktaking_item_root.visible = false;
  271. // materialTakeBack.visible = true;
  272. mainScreen.switchViewOnEx();
  273. }
  274. }
  275. }
  276. // 闪烁文字
  277. Rectangle {
  278. id: materialstocktaking_delaymatrailstocknotice
  279. x: 0
  280. y: 823
  281. width: 300
  282. height: 75 // 减去顶部圆角矩形的高度
  283. color: "#00ffffff"
  284. visible: true
  285. Image {
  286. x: 0
  287. y: 0
  288. width: 75
  289. height: 75
  290. visible: true
  291. source: "qrc:/png/takeback.png"
  292. fillMode: Image.PreserveAspectFit
  293. }
  294. Text {
  295. x: 80
  296. y: 0
  297. width: 389
  298. height: 75
  299. visible: true
  300. text: takestocknotice
  301. font.pixelSize: 30
  302. horizontalAlignment: Text.AlignLeft
  303. verticalAlignment: Text.AlignVCenter
  304. color: "#ffffff"
  305. }
  306. }
  307. // 倒计时
  308. Text {
  309. x: 514
  310. y: 823
  311. width: 389
  312. height: 75
  313. visible: true
  314. font.pixelSize: 30
  315. horizontalAlignment: Text.AlignHCenter
  316. verticalAlignment: Text.AlignVCenter
  317. color: "#ffffff"
  318. text: stockcountdownstr
  319. }
  320. Timer {
  321. interval: 100
  322. running: true
  323. repeat: true
  324. onTriggered: {
  325. if(takestock == true)
  326. {
  327. materialstocktaking_button_return.visible = false;
  328. materialstocktaking_text_title.text = "请等待物资盘点结束";
  329. if(takestockviewcount > 0)
  330. {
  331. takestockviewcount--;
  332. }
  333. else{
  334. takestockviewcount = 5;
  335. if(materialstocktaking_delaymatrailstocknotice.visible === true)
  336. {
  337. materialstocktaking_delaymatrailstocknotice.visible = false;
  338. }
  339. else{
  340. materialstocktaking_delaymatrailstocknotice.visible = true;
  341. }
  342. }
  343. if(stockcountdown > 0)
  344. {
  345. stockcountdown--;
  346. stockcountdownstr = "倒计时:" + parseInt(stockcountdown / 10) +"秒"
  347. }
  348. else{
  349. }
  350. }
  351. else{
  352. materialstocktaking_text_title.text = "本次物资盘点记录如下:";
  353. }
  354. }
  355. }
  356. function set_userinfo()
  357. {
  358. takeDatetime = Qt.formatDateTime(new Date(), "yyyy-MM-dd hh:mm:ss");
  359. backDatetime = takeDatetime;
  360. takeName = pConfig.susername;
  361. backName = pConfig.susername;
  362. stockcountdown = pConfig.srfidWorkTime / 100;
  363. takestocknotice = "物资盘点中,请耐心等待......";
  364. stockcountdownstr = "倒计时:" + parseInt(stockcountdown / 10) +"秒"
  365. takestock = true;
  366. }
  367. function slot_updatetakebackMaterial()
  368. {
  369. materialstocktaking_button_return.visible = true;
  370. takestock = false;
  371. takestocknotice = "物资盘点完成!";
  372. stockcountdownstr = "";
  373. materialstocktaking_delaymatrailstocknotice.visible = true;
  374. var elseTakelist = pConfig.stakeElseMaterialList;
  375. var elseBacklist = pConfig.sbackElseMaterialList;
  376. var bindedlist = pConfig.sbindedMaterialList;
  377. var unbindlist = pConfig.sunbindMaterialList;
  378. var elseMaterialname = pConfig.smaterialNameListElse;
  379. var elseMaterialpicture = pConfig.smaterialPictureListElse;
  380. for (var i1 = 0; i1 < elseTakelist.length; i1++) {
  381. var elseTakePng = elseMaterialpicture.hasOwnProperty(elseTakelist[i1]) ? elseMaterialpicture[elseTakelist[i1]] : "qrc:/png/unknown.png";
  382. var elseTakeName = elseMaterialname.hasOwnProperty(elseTakelist[i1]) ? elseMaterialname[elseTakelist[i1]] : "未知物资";
  383. materialstocktaking_model_dissolve.append({png:elseTakePng, name: elseTakeName, rfid: "RFID:" + elseTakelist[i1]});
  384. }
  385. for (var j1 = 0; j1 < elseBacklist.length; j1++) {
  386. var elseBackPng = elseMaterialpicture.hasOwnProperty(elseBacklist[j1]) ? elseMaterialpicture[elseBacklist[j1]] : "qrc:/png/unknown.png";
  387. var elseBackName = elseMaterialname.hasOwnProperty(elseBacklist[j1]) ? elseMaterialname[elseBacklist[j1]] : "未知物资";
  388. materialstocktaking_model_misplace.append({png:elseBackPng, name: elseBackName, rfid: "RFID:" + elseBacklist[j1]});
  389. }
  390. for (var i2 = 0; i2 < bindedlist.length; i2++) {
  391. var bindedlistPng = elseMaterialpicture.hasOwnProperty(bindedlist[i2]) ? elseMaterialpicture[bindedlist[i2]] : "qrc:/png/unknown.png";
  392. var bindedlistName = elseMaterialname.hasOwnProperty(bindedlist[i2]) ? elseMaterialname[bindedlist[i2]] : "未知物资";
  393. materialstocktaking_model_binded.append({png:bindedlistPng, name: bindedlistName, rfid: "RFID:" + bindedlist[i2]});
  394. }
  395. for (var j2 = 0; j2 < unbindlist.length; j2++) {
  396. var unbindlistPng = elseMaterialpicture.hasOwnProperty(unbindlist[j2]) ? elseMaterialpicture[unbindlist[j2]] : "qrc:/png/unknown.png";
  397. var unbindlistName = elseMaterialname.hasOwnProperty(unbindlist[j2]) ? elseMaterialname[unbindlist[j2]] : "未知物资";
  398. materialstocktaking_model_unbind.append({png:unbindlistPng, name: unbindlistName, rfid: "RFID:" + unbindlist[j2]});
  399. }
  400. var takelist = pConfig.stakeMaterialList;
  401. var backlist = pConfig.sbackMaterialList;
  402. var materialname = pConfig.smaterialNameList;
  403. var materialpicture = pConfig.smaterialPictureList;
  404. for (var i = 0; i < takelist.length; i++) {
  405. materialstocktaking_model_take.append({png:materialpicture[takelist[i]], name: materialname[takelist[i]], rfid: takelist[i]});
  406. }
  407. for (var j = 0; j < backlist.length; j++) {
  408. materialstocktaking_model_back.append({png:materialpicture[backlist[j]], name: materialname[backlist[j]], rfid: backlist[j]});
  409. }
  410. materialstocktaking_list_dissolve.visible = elseTakelist.length > 0;
  411. materialstocktaking_list_misplace.visible = elseBacklist.length > 0;
  412. materialstocktaking_list_binded.visible = bindedlist.length > 0;
  413. materialstocktaking_list_unbind.visible = unbindlist.length > 0;
  414. materialstocktaking_list_take.visible = takelist.length > 0;
  415. materialstocktaking_list_back.visible = backlist.length > 0;
  416. if (elseTakelist.length > 0 ||
  417. elseBacklist.length > 0 ||
  418. bindedlist.length > 0 ||
  419. unbindlist.length > 0 ||
  420. takelist.length > 0 ||
  421. backlist.length > 0)
  422. {
  423. materialstocktaking_list_unchanged.visible = false;
  424. }
  425. else
  426. {
  427. materialstocktaking_list_unchanged.visible = true;
  428. }
  429. }
  430. function materiallistclear()
  431. {
  432. materialstocktaking_model_dissolve.clear();
  433. materialstocktaking_model_misplace.clear();
  434. materialstocktaking_model_binded.clear();
  435. materialstocktaking_model_unbind.clear();
  436. materialstocktaking_model_take.clear();
  437. materialstocktaking_model_back.clear();
  438. materialstocktaking_list_unchanged.visible = false;
  439. materialstocktaking_list_dissolve.visible = false;
  440. materialstocktaking_list_misplace.visible = false;
  441. materialstocktaking_list_binded.visible = false;
  442. materialstocktaking_list_unbind.visible = false;
  443. materialstocktaking_list_take.visible = false;
  444. materialstocktaking_list_back.visible = false;
  445. }
  446. }