| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- <template>
- <div class="infrastructures">
- <div class="til">
- <p>{{ $t('navigation.projectFormSettings') }}</p>
- <div style="display: flex;">
- <p style="cursor:pointer;margin-left: 30px;" class="themeFontColor" @click="addJa($t('tianJiaBiaoDanZiDuan'), 'ruleForm')"><i class="el-icon-circle-plus-outline"></i>{{ $t('addTian') }}</p>
- </div>
- </div>
- <div class="tabl">
- <el-table :data="dataList" highlight-current-row v-loading="listLoading" :height="heightDoms" style="width: 100%;">
- <el-table-column type="index" :label="$t('headerTop.serialNumber')" width="250px">
- <template slot-scope="scope" >
- {{scope.$index + 1}}
- </template>
- </el-table-column>
- <el-table-column prop="customName" :label="$t('ziDingYiMingCheng')" sortable></el-table-column>
- <el-table-column prop="customType" :label="$t('types')" sortable>
- <template slot-scope="scope">
- {{scope.row.customType == '2' ? $t('weekDay.date') : (scope.row.customType == '1' ? $t('tuPian') : $t('wenBen'))}}
- </template>
- </el-table-column>
- <el-table-column :label="$t('operation')" width="280">
- <template slot-scope="scope">
- <el-button size="mini" type="primary" @click="editor(scope.row, $t('bianJiBiaoDanZiDuan'))">{{ $t('bian-ji') }}</el-button>
- <el-button size="mini" type="danger" @click="deteles(scope.row)">{{ $t('btn.delete') }}</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <!-- 弹窗 -->
- <el-dialog :title="titleTex" :visible.sync="dialogVisible" width="400px" :before-close="handleClose">
- <div>
- <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="80px" class="demo-ruleForm">
- <el-form-item :label="$t('types')">
- <el-radio-group v-model="ruleForm.customType">
- <el-radio-button label="0">{{ $t('wenBen') }}</el-radio-button>
- <el-radio-button label="1">{{ $t('tuPian') }}</el-radio-button>
- <el-radio-button label="2">{{ $t('weekDay.date') }}</el-radio-button>
- </el-radio-group>
- </el-form-item>
- <el-form-item :label="$t('names')" prop="customName">
- <el-input :placeholder="$t('qingShuRuZiDingYiMingCheng')" v-model.trim="ruleForm.customName" clearable></el-input>
- </el-form-item>
- </el-form>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogVisible = false">{{ $t('quXiao') }}</el-button>
- <el-button type="primary" @click="determine('ruleForm')" v-loading="listLoading">{{ $t('queDing') }}</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- export default {
- props: {},
- components: {},
- data() {
- return {
- heightDoms: document.documentElement.clientHeight - 130,
- titleTex: this.$t('tianJiaBiaoDanZiDuan'),
- dialogVisible: false,
- ruleForm: {
- id: '',
- companyId: '',
- customName: '',
- customType: '0'
- },
- rules: {customName: [{required: true, message: this.$t('qingShuRuZiDingYiMingCheng'), trigger: 'blur'}]},
- listLoading: false,
- user: JSON.parse(sessionStorage.getItem("user")),
- dataList: []
- };
- },
- computed: {},
- watch: {},
- created() {},
- mounted() {
- this.getObtain()
- },
- methods: {
- getObtain() {
- this.listLoading = true
- this.http.post('/project-custom/getProjectCustom', this.ruleForm,
- res => {
- this.listLoading = false
- if(res.code == 'ok') {
- this.dataList = res.data
- } else {
- this.$message({
- message: error,
- type: "error"
- });
- }
- },
- error => {
- this.listLoading = false;
- this.$message({
- message: error,
- type: "error"
- });
- });
- },
- addJa(tex) {
- if(this.dataList.length >= 10) {
- this.$message({
- message: this.$t('zuiDuoZhiNengCunZaiShiGeZiDingYiZiDuan'),
- type: 'warning'
- });
- return
- }
- if(this.$refs['ruleForm']) {
- this.$refs['ruleForm'].resetFields();
- }
- this.titleTex = tex
- this.ruleForm = {
- id: '',
- companyId: '',
- customName: '',
- customType: '0'
- },
- this.dialogVisible = true
- },
- editor(item, tex) {
- if(this.$refs['ruleForm']) {
- this.$refs['ruleForm'].resetFields();
- }
- this.titleTex = tex
- this.ruleForm = JSON.parse(JSON.stringify(item))
- this.dialogVisible = true
- },
- determine(formName) {
- this.$refs[formName].validate((valid) => {
- if (valid) {
- this.listLoading = true
- this.ruleForm.companyId = this.user.companyId
- this.http.post( '/project-custom/editProjectCustom', this.ruleForm,
- res => {
- this.listLoading = false
- if(res.code == 'ok') {
- this.$message({
- message: this.titleTex == this.$t('tianJiaBiaoDanZiDuan') ? this.$t('addsuccessful') : this.$t('editsuccess'),
- type: 'success'
- });
- this.dialogVisible = false
- this.getObtain()
- } else {
- this.$message({
- message: this.titleTex == this.$t('tianJiaBiaoDanZiDuan') ? this.$t('tianJiaShiBai') + res.msg : this.$t('bianJiShiBai') + res.msg,
- type: 'error'
- });
- }
- },
- error => {
- this.listLoading = false;
- this.$message({
- message: error,
- type: "error"
- });
- });
- } else {
- console.log('error submit!!');
- return false;
- }
- });
- },
- deteles(item) {
- this.http.post( '/project-custom/delete', {
- id: item.id
- },
- res => {
- if(res.code == 'ok') {
- this.$message({
- message: this.$t('message.successfullyDeleted'),
- type: 'success'
- });
- this.getObtain()
- } else {
- this.$message({
- message: this.$t('shanChuShiBai') + res.msg,
- type: 'error'
- });
- }
- },
- error => {
- this.$message({
- message: error,
- type: "error"
- });
- });
- }
- },
- };
- </script>
- <style scoped lang="scss">
- @import "../../assets/scss/handle";
- .themeFontColor {
- @include font_color("color");
- }
- .infrastructures {
- color: #666;
- .til {
- display: flex;
- justify-content: space-between;
- line-height: 0;
- background: #f2f2f2;
- padding: 10px 25px 10px 25px;
- align-items: center;
- p {
- font-size: 14px;
- i {
- display: inline-block;
- margin-right: 5px;
- }
- }
- }
- .tabl {
- padding-left: 15px;
- box-sizing: border-box;
- }
- }
- </style>
|