MaterialException.qml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. import QtQuick
  2. import QtQuick.Layouts
  3. import QtQuick.Controls
  4. // import com.InteractiveCore 1.0
  5. import com.InteractiveTask 1.0
  6. Item {
  7. id: materialexception
  8. x: 290
  9. y: 130
  10. width: 1600
  11. height: 920
  12. property bool takebackstat : false
  13. property bool opendoor : false
  14. signal startReader();
  15. signal signal_openLock();
  16. signal signal_takebackstat(bool stat);
  17. Connections {
  18. target: materialexception
  19. onVisibleChanged: {
  20. // 刷新数据缓存
  21. if (materialexception.visible === true )
  22. {
  23. proThread.moveCursorTo(0, 0);
  24. materialexception_exce_misplace.visible = false;
  25. // refreshListMode();
  26. // materialexception_delayTimer.start();
  27. waitPromptBox.show();
  28. var taskType = InteractiveTask.TypeMaterialExceptionRefreshListModel;
  29. interactiveCore.appendTask(
  30. taskType, "", ()=>{
  31. refreshInterface();
  32. waitPromptBox.hide();
  33. });
  34. }
  35. }
  36. }
  37. // Timer {
  38. // id: materialexception_delayTimer
  39. // interval: 500 // 1秒 = 1000毫秒
  40. // repeat: false // 只触发一次
  41. // onTriggered: {
  42. // refreshListMode();
  43. // }
  44. // }
  45. // 主体区域
  46. Rectangle {
  47. id: materialexception_main
  48. x: 0
  49. y: 0
  50. width: parent.width;
  51. height: parent.height * 0.88
  52. color: "#272b7ae9"
  53. radius: 10
  54. Row {
  55. x: 20
  56. y: 20
  57. width: parent.width - 40
  58. height: parent.height * 0.88 - 40
  59. Rectangle {
  60. id: materialexception_exce_noerror
  61. width: parent.width
  62. height: 64
  63. color: "#00ffffff"
  64. radius: 10
  65. visible: false
  66. Rectangle {
  67. x: 5
  68. y: 5
  69. width: 250
  70. height: 52
  71. color: "#ffffff"
  72. radius: 20
  73. Text {
  74. anchors.centerIn: parent
  75. font.pixelSize: 25
  76. // font.bold: true
  77. color: "#ff0000"
  78. text: "当前无异常发生"
  79. }
  80. }
  81. }
  82. Rectangle {
  83. id: materialexception_exce_misplace
  84. width: parent.width
  85. height: 400
  86. color: "#1a3782"
  87. radius: 10
  88. visible: false
  89. Rectangle {
  90. x: 5
  91. y: 5
  92. width: 250
  93. height: 52
  94. color: "#ffffff"
  95. radius: 20
  96. Text {
  97. anchors.centerIn: parent
  98. font.pixelSize: 25
  99. // font.bold: true
  100. color: "#ff0000"
  101. text: "异常类型:物资错放"
  102. }
  103. }
  104. Rectangle {
  105. x: 5
  106. y: 60
  107. width: 412
  108. height: 50
  109. color: "#1a3782"
  110. Text {
  111. horizontalAlignment: Text.AlignLeft
  112. verticalAlignment: Text.AlignVCenter
  113. anchors.fill: parent
  114. font.pixelSize: 20
  115. color: "#ffffff"
  116. text: "以下物资不属于该柜子,请取出!"
  117. }
  118. }
  119. GridView {
  120. x: 25
  121. y: 100
  122. width: parent.width - 50
  123. height: parent.height - 120
  124. cellWidth: 250
  125. cellHeight: 350
  126. model: materialexception_modelMaterialException
  127. delegate: Rectangle{
  128. width: 250
  129. height: 350
  130. color: "#00ffffff"
  131. Image {
  132. anchors.horizontalCenter: parent.horizontalCenter;
  133. y: 25
  134. width: 150
  135. height: 150
  136. visible: true
  137. source: model.materialsTypePicture
  138. fillMode: Image.PreserveAspectFit
  139. }
  140. Text {
  141. x: 0
  142. y: 185
  143. width: parent.width
  144. height: 50
  145. visible: true
  146. text: model.materialsName
  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.materialsRfid
  159. font.pixelSize: 12
  160. horizontalAlignment: Text.AlignHCenter
  161. verticalAlignment: Text.AlignVCenter
  162. color: "#ffffff"
  163. }
  164. Rectangle {
  165. x: 25
  166. y: 125
  167. width: 150
  168. height: 50
  169. color: {
  170. if (model.status === "0") return "#00ff00"; // 正常 - 绿色
  171. if (model.status === "1") return "#ff0000"; // 损坏 - 红色
  172. if (model.status === "2") return "#ff9900"; // 过期 - 橙色
  173. if (model.status === "3") return "#ff9900"; // 放错柜子 - 橙色
  174. return "gray"; // 默认颜色
  175. }
  176. visible: {
  177. return false;
  178. // return model.status !== "0";
  179. }
  180. Text {
  181. anchors.centerIn: parent
  182. // text: "待还"
  183. text:{
  184. if (model.status === "0") return "正常";
  185. if (model.status === "1") return "损坏";
  186. if (model.status === "2") return "过期";
  187. if (model.status === "3") return "放错柜子";
  188. return "未知状态"; // 默认值
  189. }
  190. font.pixelSize: 30
  191. horizontalAlignment: Text.AlignHCenter
  192. verticalAlignment: Text.AlignVCenter
  193. color: "#ffffff"
  194. }
  195. }
  196. }
  197. }
  198. }
  199. Rectangle {
  200. id: materialexception_exce_timeout
  201. width: parent.width
  202. height: 52
  203. color: "#1a3782"
  204. radius: 10
  205. visible: false
  206. Rectangle {
  207. x: 5
  208. y: 5
  209. width: 250
  210. height: 52
  211. color: "#ffffff"
  212. radius: 20
  213. Text {
  214. anchors.centerIn: parent
  215. font.pixelSize: 25
  216. // font.bold: true
  217. color: "#ff0000"
  218. text: "异常类型:超时未关锁"
  219. }
  220. }
  221. }
  222. }
  223. }
  224. // 状态栏
  225. Rectangle {
  226. id: materialexception_stat
  227. x: 0
  228. y: parent.height * 0.88
  229. width: parent.width;
  230. height: parent.height * 0.12
  231. color: "#00ffffff"
  232. radius: 10
  233. // 左侧布局
  234. Row {
  235. anchors.left: parent.left // 右对齐
  236. spacing: 10
  237. // 异常上报按钮
  238. Button {
  239. id: materialexception_btn_open
  240. y: 25
  241. width: 192
  242. height: 75
  243. background: Rectangle {
  244. color: "#ff0000"
  245. radius: 10
  246. }
  247. text: qsTr("异常上报")
  248. font.pixelSize: 30
  249. palette.buttonText: "white"
  250. Connections {
  251. target: materialexception_btn_open
  252. onClicked: {
  253. materialExceptionReport.visible = true;
  254. materialexception.visible = false;
  255. }
  256. }
  257. }
  258. }
  259. // 右侧布局
  260. Row {
  261. anchors.right: parent.right // 右对齐
  262. spacing: 10
  263. // 开柜按钮
  264. Button {
  265. id: materialexception_btn_cabinet
  266. y: 25
  267. width: 192
  268. height: 75
  269. background: Rectangle {
  270. color: "#ff0000"
  271. radius: 10
  272. }
  273. text: qsTr("开柜")
  274. font.pixelSize: 30
  275. palette.buttonText: "white"
  276. Connections {
  277. target: materialexception_btn_cabinet
  278. onClicked: {
  279. takebackstat = true;
  280. pConfig.mtakebackstat = true;
  281. pConfig.imaterworkstat = 3;
  282. signal_openLock();
  283. }
  284. }
  285. }
  286. }
  287. }
  288. Rectangle {
  289. id: materialexception_rect_autoreplace
  290. x: 250
  291. y: 823
  292. width: 500
  293. height: 75 // 减去顶部圆角矩形的高度
  294. color: "#00ffffff"
  295. visible: false
  296. Image {
  297. x: 0
  298. y: 0
  299. width: 75
  300. height: 75
  301. visible: true
  302. source: "qrc:/png/takeback.png"
  303. fillMode: Image.PreserveAspectFit
  304. }
  305. Text {
  306. x: 200
  307. y: 0
  308. width: 220
  309. height: 75
  310. visible: true
  311. text: "等待取出不属于该柜子的物资......"
  312. font.pixelSize: 30
  313. horizontalAlignment: Text.AlignHCenter
  314. verticalAlignment: Text.AlignVCenter
  315. color: "#ffffff"
  316. }
  317. }
  318. function lockStat_callback(left, right)
  319. {
  320. if (pConfig.imaterworkstat === 3)
  321. {
  322. if(left === false || right === false)
  323. {
  324. // materialreplace_btn_head_openLock.visible = false; // 柜子开时,开柜按钮隐藏
  325. materialexception_rect_autoreplace.visible = true;
  326. // materialexception_btn_open.visible = false;
  327. materialexception_btn_cabinet.enabled = false;
  328. opendoor = true;
  329. if(takebackstat === true)
  330. {
  331. signal_takebackstat(true);
  332. }
  333. }
  334. else if(left === true && right === true)
  335. {
  336. materialexception_rect_autoreplace.visible = false;
  337. // materialexception_btn_open.visible = true;
  338. materialexception_btn_cabinet.enabled = true;
  339. opendoor = false;
  340. if(takebackstat === true)
  341. {
  342. startReader();
  343. takebackstat = false;
  344. signal_takebackstat(false);
  345. pConfig.smaterialStock = true;
  346. // 开始读rfid
  347. // materialexception.visible = false;
  348. mainScreen.switchViewOffEx();
  349. materialStocktaking.set_userinfo();
  350. materialStocktaking.materiallistclear();
  351. materialStocktaking.visible = true;
  352. // materialreplace_rect_autoreplace.visible = false;
  353. mainScreen.resetLogin_timeout();
  354. }
  355. }
  356. }
  357. }
  358. // 刷新model列表
  359. function refreshListMode()
  360. {
  361. var taskType = InteractiveTask.TypeMaterialExceptionRefreshListModel;
  362. interactiveCore.appendTask(taskType, "", refreshInterface);
  363. }
  364. // 刷新界面显示
  365. function refreshInterface()
  366. {
  367. if (materialexception_modelMaterialException.count() > 0)
  368. {
  369. materialexception_exce_misplace.visible = true;
  370. materialexception_btn_cabinet.visible = true;
  371. materialexception_exce_noerror.visible = false;
  372. }
  373. else
  374. {
  375. materialexception_exce_misplace.visible = false;
  376. materialexception_btn_cabinet.visible = false;
  377. materialexception_exce_noerror.visible = true;
  378. }
  379. materialexception_exce_timeout.visible = pConfig.blocktimeout;
  380. }
  381. }