selectMachine.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <template>
  2. <view>
  3. <view class="body">
  4. <input class="input" style="display:none;" name="code" :value=code />
  5. 编码:<input class="input" v-model="code" />
  6. <button type="primary" @click="saoma()" class="" size="mini">
  7. <!-- <p class="p">扫码</p> -->
  8. 扫码
  9. </button>
  10. <button type="primary" @click="getMessage(code)" class="" size="mini">
  11. <!-- <p class="p">获取</p> -->
  12. 获取
  13. </button>
  14. </view>
  15. <view class="">
  16. <t-table>
  17. <t-tr class="tr">
  18. 机器编码:<input class="input" v-model="coding" disabled="true"/>
  19. </t-tr>
  20. <t-tr class="tr">
  21. 机器铭牌:{{nameplate != null ? nameplate : ''}}
  22. </t-tr>
  23. <t-tr class="tr">
  24. 设备编码:{{clientId != null ? clientId : ''}}
  25. </t-tr>
  26. <t-tr class="tr">
  27. 订单编码:{{orderNo != null ? orderNo : ''}}
  28. </t-tr>
  29. <t-tr class="tr">
  30. 客户编码:{{customerNo != null ? customerNo : ''}}
  31. </t-tr>
  32. <t-tr class="tr">
  33. 机器名称:{{name != null ? name : ''}}
  34. </t-tr>
  35. <t-tr class="tr">
  36. 总装开始时间:{{startDate != null ? startDate : ''}}
  37. </t-tr>
  38. <t-tr class="tr">
  39. 工序状态:{{weiname}}
  40. </t-tr>
  41. <t-tr class="tr">
  42. 模块状态:{{Modulesname}}
  43. </t-tr>
  44. <t-tr class="tr">
  45. 总装结束时间:{{endDate != null ? endDate : ''}}
  46. </t-tr>
  47. <t-tr class="tr">
  48. 刷卡器:{{cardReader != null ? cardReader : ''}}
  49. </t-tr>
  50. </t-table>
  51. </view>
  52. <view class="line"></view>
  53. <view class="">
  54. <uni-list-item title="工序查询" @click="gongxu()" />
  55. </view>
  56. <view class="line"></view>
  57. <!-- <view class="line"></view> -->
  58. <view class="">
  59. <view v-for="(item,index) in groupedModules" :key="index">
  60. <t-table class="table">
  61. <t-tr class="tr table">
  62. 名称:{{item.name}}
  63. </t-tr>
  64. <t-tr class="tr" v-for="(item1,index1) in item.items" :key="index1">
  65. <t-td>编码:{{item1.coding}}</t-td>
  66. <t-td class="td">
  67. <button type="primary" @click="tran(item1.coding)" class="button1">
  68. <p class="p">详情</p>
  69. </button>
  70. </t-td>
  71. </t-tr>
  72. </t-table>
  73. <view class="line"></view>
  74. </view>
  75. </view>
  76. </view>
  77. </template>
  78. <script>
  79. import {
  80. mapState,
  81. mapActions,
  82. mapMutations
  83. } from 'vuex';
  84. export default {
  85. data() {
  86. return {
  87. code: '',
  88. coding: '',
  89. nameplate: '',
  90. name: '',
  91. startDate: '',
  92. clientId: '',
  93. customerNo: '',
  94. orderNo: '',
  95. cardReader: '',
  96. endDate: '',
  97. modulesList: [],
  98. Modulesname: '',
  99. weiname: '',
  100. groupedModules: [], // 用于存储分组后的结果
  101. }
  102. },
  103. onShow() {
  104. },
  105. onLoad: function(option) {
  106. const item = JSON.parse(decodeURIComponent(option.item));
  107. var coding = item.coding;
  108. this.getMessage(coding);
  109. },
  110. methods: {
  111. saoma() {
  112. var that = this;
  113. // 允许从相机和相册扫码
  114. uni.scanCode({
  115. success(res) {
  116. that.code = res.result;
  117. }
  118. });
  119. },
  120. gongxu() {
  121. var item = {
  122. coding: null,
  123. type: 'get'
  124. };
  125. var coding = this.coding;
  126. item.coding = coding;
  127. uni.navigateTo({
  128. url: '../Insert/workingProcedure?item=' + encodeURIComponent(JSON.stringify(item))
  129. });
  130. },
  131. groupModules() {
  132. const grouped = {};
  133. console.log("grouped")
  134. this.modulesList.forEach(item => {
  135. if (!grouped[item.name]) {
  136. grouped[item.name] = { name: item.name, items: [] };
  137. }
  138. grouped[item.name].items.push(item);
  139. });
  140. this.groupedModules = Object.values(grouped); // 将分组结果赋值给 groupedModules
  141. console.log("groupedModules", this.groupedModules)
  142. },
  143. getMessage(coding) {
  144. var that = this;
  145. var serverUrl = that.serverurl;
  146. var token = uni.getStorageSync("token");
  147. uni.request({
  148. url: serverUrl + "/TMachine/selectMachine?coding=" + coding,
  149. method: "GET",
  150. header: {
  151. 'token': token
  152. },
  153. success: (Result) => {
  154. // console.log(Result);
  155. var res = Result;
  156. if (res.data.code == true) {
  157. //当机器已录入时,会先把所有录入模块给列出来
  158. if (res.data.message == 'all') {
  159. var tmachine = res.data.data.tmachine;
  160. that.name = tmachine.name;
  161. that.nameplate = tmachine.nameplate;
  162. that.clientId = tmachine.clientId;
  163. that.customerNo = tmachine.customerNo;
  164. that.orderNo = tmachine.orderNo;
  165. that.cardReader = tmachine.cardReader;
  166. that.coding = tmachine.coding;
  167. that.startDate = tmachine.startDate;
  168. that.endDate = tmachine.endDate;
  169. that.modulesList = res.data.data.modulesList;
  170. that.groupModules()
  171. // console.log("groupedModules", that.groupedModules)
  172. } else {
  173. var codes = res.data.data;
  174. that.name = codes.name;
  175. that.nameplate = codes.nameplate;
  176. that.clientId = codes.clientId;
  177. that.customerNo = codes.customerNo;
  178. that.orderNo = codes.orderNo;
  179. that.cardReader = codes.cardReader;
  180. that.producePersonnel = uni.getStorageSync("name");
  181. }
  182. } else {
  183. uni.showModal({
  184. title: '提示',
  185. content: res.data.message,
  186. });
  187. }
  188. this.jiancha();
  189. }
  190. });
  191. },
  192. tran(coding) {
  193. uni.setStorageSync("selectCoding", coding);
  194. uni.navigateTo({
  195. url: 'selectModules',
  196. });
  197. },
  198. jiancha() {
  199. var token = uni.getStorageSync("token");
  200. uni.request({
  201. url: this.serverurl + "/TWorkingProcedure/jiancha",
  202. method: "POST",
  203. data: {
  204. "machineCoding": this.coding
  205. },
  206. header: {
  207. 'token': token
  208. },
  209. success: (Result) => {
  210. var res = Result;
  211. if (res.data.code == false) {
  212. var re = res.data.data.toString();
  213. this.weiname = re + '未安装';
  214. } else {
  215. this.weiname = '已全部安装';
  216. }
  217. this.jianchaModules();
  218. }
  219. });
  220. },
  221. jianchaModules() {
  222. var token = uni.getStorageSync("token");
  223. uni.request({
  224. url: this.serverurl + "/TModules/jianchaModules?machineCoding=" + this.coding,
  225. method: "GET",
  226. header: {
  227. 'token': token
  228. },
  229. success: (Result) => {
  230. var res = Result;
  231. if (res.data.code == false) {
  232. var re = res.data.data.toString();
  233. this.Modulesname = re + '未安装';
  234. } else {
  235. this.Modulesname = '已全部安装';
  236. }
  237. }
  238. });
  239. }
  240. }
  241. }
  242. </script>
  243. <style>
  244. .body {
  245. background-color: #FFFFFF;
  246. padding: 20upx 20upx 20upx 20upx;
  247. font-size: 30upx;
  248. display: flex;
  249. flex-direction: row;
  250. justify-content: flex-start;
  251. }
  252. .table {
  253. padding-top: 30upx;
  254. }
  255. .tr {
  256. padding: 13upx 30upx;
  257. font-size: 30upx;
  258. }
  259. .td {
  260. padding-left: 250upx;
  261. }
  262. .input {
  263. /* padding: 10upx 20upx 10upx 0upx; */
  264. padding-left: 10upx;
  265. /* padding-top: 10upx; */
  266. margin-right: 10upx;
  267. background-color: #FFFFFF;
  268. /* width: 400upx; */
  269. height: 50upx;
  270. box-shadow: 0upx 0upx 20upx #D3D3D3;
  271. border-radius: 5upx;
  272. }
  273. .button {
  274. margin: auto;
  275. width: 60%;
  276. height: 100upx;
  277. }
  278. .button1 {
  279. margin: auto;
  280. width: 100upx;
  281. height: 55upx;
  282. }
  283. .p {
  284. /* #ifdef H5 */
  285. top: -13%;
  286. /* #endif */
  287. width: 50upx;
  288. height: 30upx;
  289. font-size: 25upx;
  290. padding-right: 9upx;
  291. padding-top: 6upx;
  292. /* #ifndef H5 */
  293. /* padding-top: 10upx; */
  294. /* #endif */
  295. position: absolute;
  296. /* 水平居中 */
  297. left: 50%;
  298. -webkit-transform: translateX(-50%);
  299. transform: translateX(-50%);
  300. }
  301. .p1 {
  302. /* #ifdef H5 */
  303. top: -13%;
  304. /* #endif */
  305. width: 80upx;
  306. height: 60upx;
  307. font-size: 40upx;
  308. padding-top: 6upx;
  309. /* #ifndef H5 */
  310. padding-top: 10upx;
  311. /* #endif */
  312. position: absolute;
  313. /* 水平居中 */
  314. left: 50%;
  315. -webkit-transform: translateX(-50%);
  316. transform: translateX(-50%);
  317. }
  318. .radio {
  319. padding-top: 20upx;
  320. padding-left: 30upx;
  321. }
  322. .lis {
  323. padding-left: 90upx;
  324. font-size: 30upx;
  325. padding-top: 5upx;
  326. }
  327. .title {
  328. padding-left: 20upx;
  329. font-size: 35upx;
  330. }
  331. .line {
  332. background: #ECECEC;
  333. height: 10upx;
  334. }
  335. </style>