MaterialReplaceAuto.qml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. import QtQuick 2.15
  2. import QtQuick.Controls 2.15
  3. Item {
  4. id: materialreplaceauto
  5. x: 290
  6. y: 130
  7. width: 1600
  8. height: 920
  9. property string takeDatetime : "2025-03-02 13:16:25"
  10. property string takeName : "张天乐"
  11. property string backDatetime : "2025-03-02 13:16:25"
  12. property string backName : "张天乐"
  13. property bool takestock : true
  14. property string takestocknotice : "物资盘点中,请耐心等待......"
  15. property int takestockviewcount : 1
  16. property int stockcountdown : 5
  17. property string stockcountdownstr : "倒计时:99秒"
  18. ListModel {
  19. id: materialreplaceauto_append_listModel
  20. }
  21. ListModel {
  22. id: materialreplaceauto_remove_listModel
  23. }
  24. Rectangle {
  25. width: 1600
  26. height: 800
  27. color: "#272b7ae9"
  28. radius: 20
  29. clip: true
  30. Rectangle {
  31. width: 1600
  32. height: 100 // 减去顶部圆角矩形的高度
  33. radius: 20
  34. clip: true
  35. color: "#8f2b7ae9"
  36. Text {
  37. x: 50
  38. y: 25
  39. width: 500
  40. height: 50
  41. visible: true
  42. text: "本次物资更换记录如下:"
  43. font.pixelSize: 30
  44. horizontalAlignment: Text.AlignLeft
  45. verticalAlignment: Text.AlignVCenter
  46. font.bold: true
  47. color: "#ffffff"
  48. }
  49. }
  50. Rectangle {
  51. x: 0
  52. y: 100
  53. width: parent.width
  54. height: (parent.height - 100) / 2
  55. color: "#002b7ae9"
  56. Text {
  57. x: 50
  58. y: 0
  59. width: 260
  60. height: 50
  61. visible: true
  62. text: takeDatetime
  63. font.pixelSize: 25
  64. horizontalAlignment: Text.AlignLeft
  65. verticalAlignment: Text.AlignVCenter
  66. font.bold: true
  67. color: "#ffffff"
  68. }
  69. Text {
  70. x: 310
  71. y: 0
  72. width: 120
  73. height: 50
  74. visible: true
  75. text: takeName
  76. font.pixelSize: 25
  77. horizontalAlignment: Text.AlignHCenter
  78. verticalAlignment: Text.AlignVCenter
  79. font.underline: true
  80. font.bold: true
  81. color: "#ffffff"
  82. }
  83. Text {
  84. x: 430
  85. y: 0
  86. width: 180
  87. height: 50
  88. visible: true
  89. text: "替换以下物资:"
  90. font.pixelSize: 25
  91. horizontalAlignment: Text.AlignHCenter
  92. verticalAlignment: Text.AlignVCenter
  93. font.bold: true
  94. color: "#ffffff"
  95. }
  96. GridView {
  97. x: 25
  98. y: 50
  99. width: parent.width - 50
  100. height: parent.height - 50
  101. cellWidth: 250 // 每个单元格的宽度,这里是平均分配宽度给5列
  102. cellHeight: 350 // 每个单元格的高度
  103. model: materialreplaceauto_append_listModel
  104. delegate: Rectangle{
  105. width: 250
  106. height: 350
  107. color: "#00ffffff"
  108. Rectangle {
  109. x: 25
  110. y: 25
  111. width: 200
  112. height: 300
  113. color: "#00ffffff"
  114. Image {
  115. x: 25
  116. y: 25
  117. width: 150
  118. height: 150
  119. visible: true
  120. source: model.png
  121. fillMode: Image.PreserveAspectFit
  122. }
  123. Text {
  124. x: 0
  125. y: 185
  126. width: parent.width
  127. height: 50
  128. visible: true
  129. text: model.name
  130. font.pixelSize: 30
  131. horizontalAlignment: Text.AlignHCenter
  132. verticalAlignment: Text.AlignVCenter
  133. color: "#ffffff"
  134. }
  135. Text {
  136. x: 0
  137. y: 250
  138. width: parent.width
  139. height: 25
  140. visible: true
  141. text: model.rfid
  142. font.pixelSize: 12
  143. horizontalAlignment: Text.AlignHCenter
  144. verticalAlignment: Text.AlignVCenter
  145. color: "#ffffff"
  146. }
  147. }
  148. }
  149. }
  150. }
  151. Rectangle {
  152. x: 0
  153. y: (parent.height - 100) / 2 + 100
  154. width: parent.width
  155. height: (parent.height - 100) / 2
  156. color: "#002b7ae9"
  157. Text {
  158. x: 50
  159. y: 0
  160. width: 260
  161. height: 50
  162. visible: true
  163. text: backDatetime
  164. font.pixelSize: 25
  165. horizontalAlignment: Text.AlignLeft
  166. verticalAlignment: Text.AlignVCenter
  167. font.bold: true
  168. color: "#ffffff"
  169. }
  170. Text {
  171. x: 310
  172. y: 0
  173. width: 120
  174. height: 50
  175. visible: true
  176. text: backName
  177. font.pixelSize: 25
  178. horizontalAlignment: Text.AlignHCenter
  179. verticalAlignment: Text.AlignVCenter
  180. font.underline: true
  181. font.bold: true
  182. color: "#ffffff"
  183. }
  184. Text {
  185. x: 430
  186. y: 0
  187. width: 180
  188. height: 50
  189. visible: true
  190. text: "新放入以下物资:"
  191. font.pixelSize: 25
  192. horizontalAlignment: Text.AlignHCenter
  193. verticalAlignment: Text.AlignVCenter
  194. font.bold: true
  195. color: "#ffffff"
  196. }
  197. GridView {
  198. x: 25
  199. y: 50
  200. width: parent.width - 50
  201. height: parent.height - 50
  202. cellWidth: 250 // 每个单元格的宽度,这里是平均分配宽度给5列
  203. cellHeight: 350 // 每个单元格的高度
  204. model: materialreplaceauto_remove_listModel
  205. delegate: Rectangle{
  206. width: 250
  207. height: 350
  208. color: "#00ffffff"
  209. Rectangle {
  210. x: 25
  211. y: 25
  212. width: 200
  213. height: 300
  214. color: "#00ffffff"
  215. Image {
  216. x: 25
  217. y: 25
  218. width: 150
  219. height: 150
  220. visible: true
  221. source: model.png
  222. fillMode: Image.PreserveAspectFit
  223. }
  224. Text {
  225. x: 0
  226. y: 185
  227. width: parent.width
  228. height: 50
  229. visible: true
  230. text: model.name
  231. font.pixelSize: 30
  232. horizontalAlignment: Text.AlignHCenter
  233. verticalAlignment: Text.AlignVCenter
  234. color: "#ffffff"
  235. }
  236. Text {
  237. x: 0
  238. y: 250
  239. width: parent.width
  240. height: 25
  241. visible: true
  242. text: model.rfid
  243. font.pixelSize: 12
  244. horizontalAlignment: Text.AlignHCenter
  245. verticalAlignment: Text.AlignVCenter
  246. color: "#ffffff"
  247. }
  248. }
  249. }
  250. }
  251. }
  252. Canvas {
  253. anchors.fill: parent
  254. onPaint: {
  255. var ctx = getContext("2d");
  256. ctx.lineWidth = 5; // 设置线的宽度
  257. ctx.strokeStyle = "skyblue"; // 设置线的颜色为白色
  258. ctx.beginPath();
  259. ctx.moveTo(5, (parent.height - 100) / 2 + 100); // 直线的起点
  260. ctx.lineTo(parent.width - 5, (parent.height - 100) / 2 + 100); // 直线的终点
  261. ctx.stroke(); // 绘制直线
  262. }
  263. }
  264. }
  265. Button {
  266. id: button_return
  267. x: 1408
  268. y: 835
  269. width: 192
  270. height: 75
  271. background: Rectangle {
  272. color: "#055eb3" // 设置背景为透明
  273. radius: 10 // 可选,设置圆角
  274. }
  275. text: qsTr("返回")
  276. font.pixelSize: 30
  277. palette.buttonText: "white" // 设置字体颜色为绿色
  278. Connections {
  279. target: button_return
  280. onClicked: {
  281. materialreplaceauto.visible = false;
  282. materialReplace.visible = true;
  283. }
  284. }
  285. }
  286. Rectangle {
  287. id: delaymatrailstocknoticeauto
  288. x: 0
  289. y: 823
  290. width: 300
  291. height: 75 // 减去顶部圆角矩形的高度
  292. color: "#00ffffff"
  293. visible: true
  294. Image {
  295. x: 0
  296. y: 0
  297. width: 75
  298. height: 75
  299. visible: true
  300. source: "qrc:/png/takeback.png"
  301. fillMode: Image.PreserveAspectFit
  302. }
  303. Text {
  304. x: 80
  305. y: 0
  306. width: 389
  307. height: 75
  308. visible: true
  309. text: takestocknotice
  310. font.pixelSize: 30
  311. horizontalAlignment: Text.AlignLeft
  312. verticalAlignment: Text.AlignVCenter
  313. color: "#ffffff"
  314. }
  315. }
  316. Text {
  317. x: 514
  318. y: 823
  319. width: 389
  320. height: 75
  321. visible: true
  322. font.pixelSize: 30
  323. horizontalAlignment: Text.AlignHCenter
  324. verticalAlignment: Text.AlignVCenter
  325. color: "#ffffff"
  326. text: stockcountdownstr
  327. }
  328. Timer {
  329. interval: 100
  330. running: true
  331. repeat: true
  332. onTriggered: {
  333. if(takestock == true)
  334. {
  335. if(takestockviewcount > 0)
  336. {
  337. takestockviewcount--;
  338. }
  339. else{
  340. takestockviewcount = 5;
  341. if(delaymatrailstocknoticeauto.visible === true)
  342. {
  343. delaymatrailstocknoticeauto.visible = false;
  344. }
  345. else{
  346. delaymatrailstocknoticeauto.visible = true;
  347. }
  348. }
  349. if(stockcountdown > 0)
  350. {
  351. stockcountdown--;
  352. stockcountdownstr = "倒计时:" + parseInt(stockcountdown / 10) +"秒"
  353. }
  354. else{
  355. }
  356. }
  357. else{
  358. delaymatrailstocknoticeauto.visible = true;
  359. }
  360. }
  361. }
  362. function set_userinfo()
  363. {
  364. takeDatetime = Qt.formatDateTime(new Date(), "yyyy-MM-dd hh:mm:ss");
  365. backDatetime = takeDatetime;
  366. takeName = pConfig.susername;
  367. backName = pConfig.susername;
  368. stockcountdown = pConfig.srfidWorkTime / 100;
  369. takestocknotice = "物资更换中,请耐心等待......";
  370. stockcountdownstr = "倒计时:" + parseInt(stockcountdown / 10) +"秒"
  371. takestock = true;
  372. }
  373. function slot_updatetakebackMaterial()
  374. {
  375. takestock = false;
  376. takestocknotice = "物资更换完成!";
  377. stockcountdownstr = "";
  378. delaymatrailstocknoticeauto.visible = true;
  379. var takelist = pConfig.stakeMaterialList;
  380. var backlist = pConfig.sbackMaterialList;
  381. var materialname = pConfig.smaterialNameList;
  382. var materialpicture = pConfig.smaterialPictureList;
  383. for (var i = 0; i < takelist.length; i++) {
  384. materialreplaceauto_append_listModel.append({png:materialpicture[takelist[i]], name: materialname[takelist[i]], rfid: takelist[i]});
  385. }
  386. for (var j = 0; j < backlist.length; j++) {
  387. materialreplaceauto_remove_listModel.append({png:materialpicture[backlist[j]], name: materialname[backlist[j]], rfid: backlist[j]});
  388. }
  389. }
  390. function materiallistclear()
  391. {
  392. materialreplaceauto_append_listModel.clear();
  393. materialreplaceauto_remove_listModel.clear();
  394. }
  395. }