maintenance.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. var _this;
  2. var nowTime = new Date().getTime();
  3. var periodChart, typeChart;
  4. new Vue({
  5. el: '#app',
  6. filters: {
  7. getImgList(key){
  8. return [fileUrl+key];
  9. }
  10. },
  11. data: function() {
  12. return {
  13. queryParams: {
  14. pageNum: 1,
  15. pageSize: 10,
  16. orderByColumn: "createTime",
  17. isAsc: "descending",
  18. createBy: "31"
  19. },
  20. maintaiList: [],
  21. allTotal: 0,
  22. maintainForm: {},
  23. title: "",
  24. rules: {
  25. shipName: [{
  26. required: true, message: "船舶名称不能为空", trigger: "blur"
  27. }],
  28. maintainEquipment: [{
  29. required: true, message: "设备名称不能为空", trigger: "blur"
  30. }],
  31. maintailBefore: [{
  32. required: true, message: "维修日期不能为空", trigger: "blur"
  33. }],
  34. maintailRemarkBefore: [{
  35. required: true, message: "故障描述不能为空", trigger: "blur"
  36. }],
  37. },
  38. upHeaders: {},
  39. imgUrl: '',
  40. maintenanceState: [],
  41. drawerDolag: false,
  42. open: false
  43. }
  44. },
  45. created() {
  46. _this = this;
  47. _this.upHeaders = {
  48. "Authorization": "Bearer " + getCookie("tzToken")
  49. };
  50. _this.imgUrl = fileUrl;
  51. let _obj = getUseDict("com_maintenance_record_state")
  52. setTimeout(()=>{
  53. _this.maintenanceState = _obj["com_maintenance_record_state"];
  54. this.getList();
  55. }, 500);
  56. },
  57. mounted:function(){
  58. },
  59. methods: {
  60. getList(){
  61. // setFileLogin()
  62. getMaintenanceList(_this.queryParams).then((_res) => {
  63. _this.maintaiList = _res.rows;
  64. _this.allTotal = _res.total;
  65. });
  66. },
  67. handleQuery() {
  68. _this.queryParams.pageNum = 1;
  69. this.getList();
  70. },
  71. resetQuery() {
  72. _this.queryParams = {
  73. pageNum: 1,
  74. pageSize: 10,
  75. orderByColumn: "createTime",
  76. isAsc: "descending"
  77. }
  78. this.handleQuery();
  79. },
  80. handleCurrentChange(val) {
  81. if(val != _this.queryParams.pageNum){
  82. _this.queryParams.pageNum = val;
  83. this.getList();
  84. }
  85. },
  86. handleAdd(){
  87. this.reset();
  88. _this.open = true;
  89. _this.title = "添加维修清单";
  90. },
  91. reset(){
  92. _this.maintainForm = {
  93. maintainRecordId: null,
  94. maintailType: 10,
  95. maintainEquipment: "",
  96. maintailBefore: "",
  97. maintailRemarkBefore: "",
  98. shipName: ""
  99. }
  100. },
  101. handleSubmit(){
  102. if (_this.maintainForm.maintainRecordId != null) {
  103. if(_this.maintainForm.shipName.length&&_this.maintainForm.maintainEquipment.length){
  104. _this.maintainForm.maintailType = 20;
  105. updateMaintain(_this.maintainForm).then(response => {
  106. this.$message({
  107. showClose: true,
  108. message: "新增成功",
  109. type: 'success'
  110. });
  111. _this.open = false;
  112. this.getList();
  113. });
  114. }
  115. }else{
  116. if(_this.maintainForm.shipName.length&&_this.maintainForm.maintainEquipment.length&&_this.maintainForm.maintailRemarkBefore.length&&_this.maintainForm.maintailBefore.length){
  117. addMaintain(_this.maintainForm).then(response => {
  118. this.$message({
  119. showClose: true,
  120. message: "新增成功",
  121. type: 'success'
  122. });
  123. _this.open = false;
  124. this.getList();
  125. });
  126. }
  127. }
  128. },
  129. handleAvatarSuccess(res, file) {
  130. if(_this.open){
  131. _this.maintainForm.maintailBeforeUrl = res.fileName;
  132. }else if(_this.drawerDolag){
  133. _this.maintainForm.maintailEndUrl = res.fileName;
  134. }
  135. },
  136. beforeAvatarUpload(file) {
  137. const fileType = ["png", "jpg", "jpeg"];
  138. const isLt2M = file.size / 1024 / 1024 < 5;
  139. let fileExtension = "";
  140. if (file.name.lastIndexOf(".") > -1) {
  141. fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
  142. }
  143. isImg = fileType.some(type => {
  144. if (file.type.indexOf(type) > -1) return true;
  145. if (fileExtension && fileExtension.indexOf(type) > -1) return true;
  146. return false;
  147. });
  148. if (!isImg) {
  149. this.$message.error('上传头像图片只能是 "png", "jpg", "jpeg" 格式!');
  150. }
  151. if (!isLt2M) {
  152. this.$message.error('上传头像图片大小不能超过 5MB!');
  153. }
  154. return isImg && isLt2M;
  155. },
  156. handleDelete(row) {
  157. this.$confirm('是否确认删除改条维修记录为"' + row.maintainRecordId + '"的数据项?').then(function () {
  158. return DelMaintenance(row.maintainRecordId);
  159. }).then(() => {
  160. this.getList();
  161. this.$message({
  162. showClose: true,
  163. message: "删除成功",
  164. type: 'success'
  165. });
  166. }).catch(() => { });
  167. },
  168. handleSee(row){
  169. getMaintenanceDetail(row.maintainRecordId).then((_res) => {
  170. _this.maintainForm = _res.data;
  171. _this.drawerDolag = true;
  172. });
  173. }
  174. }
  175. })