selectModules.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <view>
  3. <form @submit="add">
  4. <view class="body">
  5. <input class="input" style="display:none;" name="coding" :value=coding />
  6. 编码:<input class="input" v-model="coding" />
  7. <button type="primary" @click="saoma()" class="button1">
  8. <p class="p">扫码</p>
  9. </button>
  10. <button type="primary" @click="getMessage(coding)" class="button1">
  11. <p class="p">获取</p>
  12. </button>
  13. </view>
  14. <view class="">
  15. <t-table>
  16. <t-tr class="tr">
  17. 名称:{{name}}
  18. </t-tr>
  19. <t-tr class="tr">
  20. 所属机器编码:{{machineCoding}}
  21. </t-tr>
  22. <t-tr class="tr">
  23. 版本号:{{versions}}
  24. </t-tr>
  25. <t-tr class="tr">
  26. 生产人员:{{producePersonnel}}
  27. </t-tr>
  28. <t-tr class="tr">
  29. 生产日期:{{produceDate}}
  30. </t-tr>
  31. <view class="" v-if="installPersonnel!=''&&installPersonnel!=null">
  32. <t-tr class="tr">
  33. 装配人员:{{installPersonnel}}
  34. </t-tr>
  35. <t-tr class="tr">
  36. 装配日期:{{installDate}}
  37. </t-tr>
  38. </view>
  39. <view class="" v-if="replacePersonnel!=''&&replacePersonnel!=null">
  40. <t-tr class="tr">
  41. 更换人员:{{replacePersonnel}}
  42. </t-tr>
  43. <t-tr class="tr">
  44. 更换原因:{{replaceReason}}
  45. </t-tr>
  46. <t-tr class="tr">
  47. 原模板编号:{{oldCoding}}
  48. </t-tr>
  49. <t-tr class="tr">
  50. 更换日期:{{replateDate}}
  51. </t-tr>
  52. </view>
  53. <t-tr class="tr">
  54. 状态:{{status}}
  55. </t-tr>
  56. <t-tr class="ttr">
  57. 操作:
  58. <button v-show="status!=''" type="primary" @click="change(coding,machineCoding)"
  59. class="button1">
  60. <p class="p">更换</p>
  61. </button>
  62. <button v-if="level>2" type="primary" @click="del(coding)" class="button1">
  63. <p class="p">删除</p>
  64. </button>
  65. </t-tr>
  66. </t-table>
  67. </view>
  68. <view class="title">配件</view>
  69. <!-- <view class="lis" v-for="item in desList">
  70. {{item}}
  71. </view> -->
  72. <view class="lis" v-for="(item,index) in desList" :key="index">
  73. {{item}}
  74. </view>
  75. </form>
  76. </view>
  77. </template>
  78. <script>
  79. import {
  80. mapState,
  81. mapActions,
  82. mapMutations
  83. } from 'vuex';
  84. import timeSelector from '@/components/wing-time-selector/wing-time-selector.vue';
  85. export default {
  86. components: {
  87. timeSelector
  88. },
  89. data() {
  90. return {
  91. oldCoding: '',
  92. replateDate: '',
  93. replaceReason: '',
  94. replacePersonnel: '',
  95. installDate: '',
  96. installPersonnel: '',
  97. produceDate: '',
  98. coding: '',
  99. name: '',
  100. versions: '',
  101. producePersonnel: '',
  102. machineCoding: '',
  103. status: '',
  104. level: 0,
  105. desList: {}
  106. }
  107. },
  108. onShow() {
  109. var token = uni.getStorageSync("token");
  110. if (token.length > 2) {
  111. var coding = uni.getStorageSync("selectCoding");
  112. if (coding.length > 2) {
  113. this.coding = coding;
  114. this.getMessage(coding);
  115. }
  116. }
  117. var level = uni.getStorageSync("level");
  118. this.level = level;
  119. },
  120. methods: {
  121. saoma() {
  122. var that = this;
  123. // 允许从相机和相册扫码
  124. uni.scanCode({
  125. success(res) {
  126. that.coding = res.result;
  127. }
  128. });
  129. },
  130. del(coding) {
  131. uni.showModal({
  132. title: '删除',
  133. content: '确定执行操作?',
  134. success: (res) => {
  135. if (res.confirm) {
  136. var that = this;
  137. var serverUrl = that.serverurl;
  138. var token = uni.getStorageSync("token");
  139. uni.request({
  140. url: serverUrl + "/TModules/deleteModules?coding=" + coding,
  141. method: "GET",
  142. header: {
  143. 'token': token
  144. },
  145. success: (Result) => {
  146. // console.log(Result);
  147. var res = Result;
  148. uni.showModal({
  149. title: '提示',
  150. content: res.data.message,
  151. });
  152. }
  153. });
  154. }
  155. }
  156. });
  157. },
  158. change(coding, machineCoding) {
  159. uni.navigateTo({
  160. url: '/pages/select/update?coding=' + coding + '&machineCoding=' + machineCoding,
  161. });
  162. },
  163. getMessage(coding) {
  164. var that = this;
  165. var serverUrl = that.serverurl;
  166. var token = uni.getStorageSync("token");
  167. uni.request({
  168. url: serverUrl + "/TModules/getModules?coding=" + coding,
  169. method: "GET",
  170. header: {
  171. 'token': token
  172. },
  173. success: (Result) => {
  174. console.log("1");
  175. var res = Result;
  176. if (res.data.code == true) {
  177. var codes = res.data.data;
  178. that.name = codes.name;
  179. var co = codes.coding;
  180. if (co.substring(0, 4) != '1000') {
  181. that.versions = co.substring(8, 10);
  182. that.producePersonnel = codes.producePersonnel;
  183. that.produceDate = codes.createDate;
  184. var sta = codes.status;
  185. if (sta == '0') {
  186. that.status = "未安装";
  187. }
  188. if (sta == '1') {
  189. that.status = "已安装";
  190. }
  191. if (sta == '2') {
  192. that.status = "已替换";
  193. }
  194. that.machineCoding = codes.machineCoding;
  195. } else {
  196. that.versions = co.substring(co.length - 3, co.length);
  197. // that.producePersonnel = "";
  198. // that.produceDate = "";
  199. var sta = codes.status;
  200. if (sta == '0') {
  201. that.status = "未安装";
  202. }
  203. if (sta == '1') {
  204. that.status = "已安装";
  205. }
  206. if (sta == '2') {
  207. that.status = "已替换";
  208. }
  209. that.producePersonnel = codes.producePersonnel;
  210. that.produceDate = codes.createDate;
  211. if (codes.machineCoding != null) {
  212. that.machineCoding = codes.machineCoding;
  213. }
  214. }
  215. if (codes.flagCode.length > 1) {
  216. that.desList = codes.flagCode.split(",");
  217. }
  218. that.installDate = codes.installDate;
  219. that.installPersonnel = codes.installPersonnel;
  220. that.replateDate = codes.replateDate;
  221. that.replaceReason = codes.replaceReason;
  222. that.replacePersonnel = codes.replacePersonnel;
  223. if (co.substring(0, 4) != '1000') {
  224. that.oldCoding = "";
  225. } else {
  226. that.oldCoding = "";
  227. }
  228. } else {
  229. uni.showModal({
  230. content: res.data.message,
  231. });
  232. }
  233. }
  234. });
  235. }
  236. }
  237. }
  238. </script>
  239. <style>
  240. .body {
  241. background-color: #FFFFFF;
  242. padding: 20upx 20upx 20upx 20upx;
  243. font-size: 30upx;
  244. display: flex;
  245. flex-direction: row;
  246. justify-content: flex-start;
  247. }
  248. .ttr {
  249. padding-left: 30upx;
  250. padding-top: 13upx;
  251. font-size: 30upx;
  252. padding-bottom: 13upx;
  253. display: flex;
  254. flex-direction: row;
  255. justify-content: flex-start;
  256. }
  257. .tr {
  258. padding-left: 30upx;
  259. padding-top: 13upx;
  260. font-size: 30upx;
  261. padding-bottom: 13upx;
  262. }
  263. .input {
  264. /* padding: 10upx 20upx 10upx 0upx; */
  265. padding-left: 20upx;
  266. padding-top: 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: 75upx;
  281. height: 50upx;
  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. </style>