assetsHandle.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <template>
  2. <div class="detail">
  3. <mt-header class="detail_head" fixed title="处置资产">
  4. <router-link to="" slot="left">
  5. <mt-button icon="back" v-on:click="jumpBack()"></mt-button>
  6. </router-link>
  7. </mt-header>
  8. <div class="detail_body">
  9. <div class="detailBox">
  10. <mt-field label="资产编号" placeholder="请输入物品名称" v-model="detail.modelNo" disabled></mt-field>
  11. <mt-field id="state" label="资产状态" placeholder="请选择资产状态" disableClear disabled v-on:click.native="chooseType()" v-model="state"></mt-field>
  12. <mt-field v-if="assetsForm.state == 1" id="userId" label="对应人员" placeholder="请选择对应人员" disableClear disabled v-on:click.native="choosePeo()" v-model="userName"></mt-field>
  13. </div>
  14. <div class="btn">
  15. <mt-button class="allBtn" size="large" type="primary" v-on:click.native="submit()">确定</mt-button>
  16. <mt-button class="allBtn" size="large" v-on:click.native="jumpBack()">取消</mt-button>
  17. </div>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. id: this.$route.params.id,
  26. user: JSON.parse(sessionStorage.getItem("user")),
  27. detail: "",
  28. users: [],
  29. assetsForm: {
  30. id: '',
  31. state: 0,
  32. userId: 0,
  33. currentUserId: JSON.parse(sessionStorage.getItem("user")).id,
  34. },
  35. state: "",
  36. userName: "",
  37. popupVisible: false,
  38. canClick: true,
  39. }
  40. },
  41. methods: {
  42. // 详情
  43. getDetail() {
  44. this.$indicator.open();
  45. this.http.post(this.port.assets.detailNo, {
  46. 'id': this.id
  47. } ,
  48. res => {
  49. this.$indicator.close();
  50. if (res.code == "ok") {
  51. this.detail = res.data;
  52. this.assetsForm = {
  53. id: res.data.id,
  54. state: res.data.state,
  55. userId: res.data.userId == null?0:res.data.userId,
  56. currentUserId: JSON.parse(sessionStorage.getItem("user")).id,
  57. }
  58. if(res.data.state == 0) {
  59. this.state = "未用"
  60. } else if(res.data.state == 1) {
  61. this.state = "在用"
  62. } else if(res.data.state == 3) {
  63. this.state = "报废"
  64. }
  65. this.userName = res.data.username==null?'':res.data.username;
  66. } else {
  67. this.$toast({
  68. message: res.msg,
  69. duration: 2000
  70. });
  71. }
  72. }, error => {
  73. this.$indicator.close();
  74. this.$toast({
  75. message: error,
  76. duration: 2000
  77. });
  78. })
  79. },
  80. getUserList() {
  81. this.http.post(this.port.user.list, {} ,
  82. res => {
  83. if (res.code == "ok") {
  84. for(var i in res.data) {
  85. // if(res.data[i].departmentGuid == this.user.deptId) {
  86. var list = res.data[i].userVOS;
  87. for(var j in list) {
  88. this.users.push({
  89. id: list[j].id,
  90. name: list[j].name,
  91. })
  92. }
  93. // }
  94. }
  95. } else {
  96. this.$toast({
  97. message: res.msg,
  98. duration: 2000
  99. });
  100. }
  101. }, error => {
  102. this.$toast({
  103. message: error,
  104. duration: 2000
  105. });
  106. })
  107. },
  108. chooseType() {
  109. var _this = this;
  110. var dataShippingSpace = [];
  111. if(this.detail.state == 0) {
  112. dataShippingSpace = [
  113. {name: "在用"},
  114. {name: "报废"},
  115. ];
  116. } else if(this.detail.state == 1) {
  117. dataShippingSpace = [
  118. {name: "未用"},
  119. ];
  120. }
  121. var pickerDiv = document.getElementById("state");
  122. var vCardType = this.detail.state;
  123. var pickerView = new PickerView({
  124. bindElem: pickerDiv,
  125. data: dataShippingSpace,
  126. title: "资产状态",
  127. leftText: "取消",
  128. rightText: "确定",
  129. rightFn: function(selectArr) {
  130. if (selectArr[0].name == "未用") {
  131. vCardType = "0";
  132. _this.assetsForm.state = 0;
  133. _this.assetsForm.userId = 0;
  134. _this.state = "未用";
  135. } else if (selectArr[0].name == "在用") {
  136. vCardType = "1";
  137. _this.assetsForm.state = 1;
  138. _this.state = "在用";
  139. } else if (selectArr[0].name == "报废") {
  140. vCardType = "3";
  141. _this.assetsForm.state = 3;
  142. _this.assetsForm.userId = 0;
  143. _this.state = "报废";
  144. }
  145. }
  146. });
  147. },
  148. choosePeo() {
  149. if(this.detail.state != 1) {
  150. var _this = this;
  151. var dataShippingSpace = this.users;
  152. var pickerDiv = document.getElementById("userId");
  153. var vCardType = this.detail.userId;
  154. var pickerView = new PickerView({
  155. bindElem: pickerDiv,
  156. data: dataShippingSpace,
  157. title: "对应人员",
  158. leftText: "取消",
  159. rightText: "确定",
  160. rightFn: function(selectArr) {
  161. _this.assetsForm.userId = selectArr[0].id;
  162. _this.userName = selectArr[0].name;
  163. }
  164. });
  165. }
  166. },
  167. // 创建
  168. submit() {
  169. if(this.canClick) {
  170. this.canClick = false;
  171. if(this.assetsForm.state == 1 && this.assetsForm.userId == 0) {
  172. this.$toast({
  173. message: '请选择对应人员',
  174. duration: 2000
  175. });
  176. this.canClick = true;
  177. return false;
  178. } else if(this.detail.state == this.assetsForm.state) {
  179. this.$toast({
  180. message: '请更改状态后提交',
  181. duration: 2000
  182. });
  183. this.canClick = true;
  184. return false;
  185. } else {
  186. this.$indicator.open();
  187. var _this = this;
  188. this.http.post( this.port.assets.handle, this.assetsForm,
  189. res => {
  190. this.$indicator.close();
  191. if (res.code == "ok") {
  192. this.$toast({
  193. message: '处置成功',
  194. duration: 2000
  195. });
  196. setTimeout(function(){
  197. _this.$router.go(-1);
  198. }, 1000);
  199. } else {
  200. this.canClick = true;
  201. this.$toast({
  202. message: res.msg,
  203. duration: 2000
  204. });
  205. }
  206. },
  207. error => {
  208. this.canClick = true;
  209. this.$indicator.close();
  210. this.$toast({
  211. message: error,
  212. duration: 2000
  213. });
  214. });
  215. }
  216. } else {
  217. this.$toast({
  218. message: '请勿重复提交',
  219. duration: 2000
  220. });
  221. }
  222. },
  223. jumpBack() {
  224. this.$router.go(-1);
  225. }
  226. },
  227. created() {
  228. this.getDetail();
  229. this.getUserList();
  230. },
  231. mounted() {
  232. }
  233. }
  234. </script>
  235. <style scoped>
  236. .detail_head {
  237. background: #fff;
  238. color: #333;
  239. height: 0.4rem;
  240. }
  241. .detail_body {
  242. margin-top: 0.4rem;
  243. padding-bottom: 0.15rem;
  244. }
  245. .detail {
  246. background: #EFEFEF;
  247. overflow: hidden;
  248. }
  249. .detailBox {
  250. background: #fff;
  251. margin-bottom: 0.11rem;
  252. }
  253. .left{
  254. float:left;
  255. margin: 0.15rem;
  256. }
  257. .upload .left {
  258. margin: 0.1rem 0.11rem;
  259. }
  260. .right div{
  261. line-height: 0.21rem;
  262. white-space: nowrap;
  263. overflow: hidden;
  264. text-overflow: ellipsis;
  265. }
  266. .btn {
  267. width: 80%;
  268. margin: 0.2rem auto 80px;
  269. }
  270. .allocation {
  271. width: 100%;
  272. height: 100%;
  273. }
  274. .address_first .current{
  275. background:#eee;
  276. color: #6f83ff;
  277. border-left: 2px solid #6f83ff;
  278. }
  279. .right > ul {
  280. margin: 0;
  281. padding: 0;
  282. overflow: auto;
  283. -webkit-transition-duration: 0.4s;
  284. box-sizing:border-box;
  285. padding: 0.08rem 0.1rem;
  286. }
  287. .right > ul > li {
  288. display: inline-block;
  289. height: 0.2rem;
  290. line-height: 0.2rem;
  291. font-size: 0.14rem;
  292. color: #ccc;
  293. padding: 0 0.12rem;
  294. margin: 0.06rem 0.03rem;
  295. border: 1px solid #ccc;
  296. border-radius: 50px;
  297. min-width: 0.3rem;
  298. text-align: center;
  299. }
  300. .right > ul > li.add {
  301. border: 1px solid #777;
  302. color: #777;
  303. }
  304. .right > ul > li.active {
  305. border: 1px solid #2680EB;
  306. color: #2680EB;
  307. }
  308. .upload_add {
  309. display: inline-block;
  310. margin-bottom: 0.2rem;
  311. }
  312. .upload_add_image {
  313. padding-top: 0.08rem;
  314. margin: 0.15rem 0 0 0.3rem ;
  315. width: 1rem;
  316. height: 0.9rem;
  317. border: 1px dashed rgba(0, 0, 0, .2);
  318. }
  319. .upload_add-image .camera {
  320. font-size: 24px;
  321. }
  322. .upload_add_image p {
  323. padding: 0;
  324. margin: 0;
  325. color: #8e8e8e;
  326. }
  327. .right div img.pic {
  328. width: 0.8rem;
  329. height: 0.8rem;
  330. margin: 0.15rem 0 0 0.3rem ;
  331. }
  332. .textColor {
  333. margin-top: 0.4rem;
  334. color: #8e8e8e;
  335. padding: 0.12rem;
  336. font-size: 0.12rem;
  337. }
  338. .example {
  339. color: #8e8e8e;
  340. padding: 0.02rem 0.12rem;
  341. font-size: 0.12rem;
  342. }
  343. .allBtn {
  344. width: 80%;
  345. margin: 0.18rem auto;
  346. }
  347. </style>
  348. <style>
  349. .detail_head .mint-header-title {
  350. font-weight: 600;
  351. font-size: 0.15rem;
  352. }
  353. .detail_head .mint-button-text {
  354. color: #26a2ff;
  355. }
  356. .detailBox .mint-cell {
  357. padding: 0 0 0 0.02rem;
  358. }
  359. .mint-popup.allocation {
  360. background: #efefef;
  361. }
  362. .mint-msgbox {
  363. width: 70%;
  364. }
  365. .mint-cell-wrapper {
  366. background-image: none;
  367. }
  368. input:disabled {
  369. background: #fff;
  370. }
  371. </style>