123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- var _this;
- var nowTime = new Date().getTime();
- var periodChart, typeChart;
- new Vue({
- el: '#app',
- filters: {
- getImgList(key){
- return [fileUrl+key];
- }
- },
- data: function() {
- return {
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- orderByColumn: "createTime",
- isAsc: "descending",
- createBy: "31"
- },
- maintaiList: [],
- allTotal: 0,
- maintainForm: {},
- title: "",
- rules: {
- shipName: [{
- required: true, message: "船舶名称不能为空", trigger: "blur"
- }],
- maintainEquipment: [{
- required: true, message: "设备名称不能为空", trigger: "blur"
- }],
- maintailBefore: [{
- required: true, message: "维修日期不能为空", trigger: "blur"
- }],
- maintailRemarkBefore: [{
- required: true, message: "故障描述不能为空", trigger: "blur"
- }],
- },
- upHeaders: {},
- imgUrl: '',
- maintenanceState: [],
- drawerDolag: false,
- open: false
- }
- },
- created() {
- _this = this;
- _this.upHeaders = {
- "Authorization": "Bearer " + getCookie("tzToken")
- };
- _this.imgUrl = fileUrl;
- let _obj = getUseDict("com_maintenance_record_state")
- setTimeout(()=>{
- _this.maintenanceState = _obj["com_maintenance_record_state"];
- this.getList();
- }, 500);
- },
- mounted:function(){
- },
- methods: {
- getList(){
- // setFileLogin()
- getMaintenanceList(_this.queryParams).then((_res) => {
- _this.maintaiList = _res.rows;
- _this.allTotal = _res.total;
- });
- },
- handleQuery() {
- _this.queryParams.pageNum = 1;
- this.getList();
- },
- resetQuery() {
- _this.queryParams = {
- pageNum: 1,
- pageSize: 10,
- orderByColumn: "createTime",
- isAsc: "descending"
- }
- this.handleQuery();
- },
- handleCurrentChange(val) {
- if(val != _this.queryParams.pageNum){
- _this.queryParams.pageNum = val;
- this.getList();
- }
- },
- handleAdd(){
- this.reset();
- _this.open = true;
- _this.title = "添加维修清单";
- },
- reset(){
- _this.maintainForm = {
- maintainRecordId: null,
- maintailType: 10,
- maintainEquipment: "",
- maintailBefore: "",
- maintailRemarkBefore: "",
- shipName: ""
- }
- },
- handleSubmit(){
- if (_this.maintainForm.maintainRecordId != null) {
- if(_this.maintainForm.shipName.length&&_this.maintainForm.maintainEquipment.length){
- _this.maintainForm.maintailType = 20;
- updateMaintain(_this.maintainForm).then(response => {
- this.$message({
- showClose: true,
- message: "新增成功",
- type: 'success'
- });
- _this.open = false;
- this.getList();
- });
- }
- }else{
- if(_this.maintainForm.shipName.length&&_this.maintainForm.maintainEquipment.length&&_this.maintainForm.maintailRemarkBefore.length&&_this.maintainForm.maintailBefore.length){
- addMaintain(_this.maintainForm).then(response => {
- this.$message({
- showClose: true,
- message: "新增成功",
- type: 'success'
- });
- _this.open = false;
- this.getList();
- });
- }
- }
- },
- handleAvatarSuccess(res, file) {
- if(_this.open){
- _this.maintainForm.maintailBeforeUrl = res.fileName;
- }else if(_this.drawerDolag){
- _this.maintainForm.maintailEndUrl = res.fileName;
- }
-
- },
- beforeAvatarUpload(file) {
- const fileType = ["png", "jpg", "jpeg"];
- const isLt2M = file.size / 1024 / 1024 < 5;
- let fileExtension = "";
- if (file.name.lastIndexOf(".") > -1) {
- fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
- }
- isImg = fileType.some(type => {
- if (file.type.indexOf(type) > -1) return true;
- if (fileExtension && fileExtension.indexOf(type) > -1) return true;
- return false;
- });
- if (!isImg) {
- this.$message.error('上传头像图片只能是 "png", "jpg", "jpeg" 格式!');
- }
- if (!isLt2M) {
- this.$message.error('上传头像图片大小不能超过 5MB!');
- }
- return isImg && isLt2M;
- },
- handleDelete(row) {
- this.$confirm('是否确认删除改条维修记录为"' + row.maintainRecordId + '"的数据项?').then(function () {
- return DelMaintenance(row.maintainRecordId);
- }).then(() => {
- this.getList();
- this.$message({
- showClose: true,
- message: "删除成功",
- type: 'success'
- });
- }).catch(() => { });
- },
- handleSee(row){
- getMaintenanceDetail(row.maintainRecordId).then((_res) => {
- _this.maintainForm = _res.data;
- _this.drawerDolag = true;
- });
- }
- }
- })
|