projectForm.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <div class="infrastructures">
  3. <div class="til">
  4. <p>{{ $t('navigation.projectFormSettings') }}</p>
  5. <div style="display: flex;">
  6. <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>
  7. </div>
  8. </div>
  9. <div class="tabl">
  10. <el-table :data="dataList" highlight-current-row v-loading="listLoading" :height="heightDoms" style="width: 100%;">
  11. <el-table-column type="index" :label="$t('headerTop.serialNumber')" width="250px">
  12. <template slot-scope="scope" >
  13. {{scope.$index + 1}}
  14. </template>
  15. </el-table-column>
  16. <el-table-column prop="customName" :label="$t('ziDingYiMingCheng')" sortable></el-table-column>
  17. <el-table-column prop="customType" :label="$t('types')" sortable>
  18. <template slot-scope="scope">
  19. {{scope.row.customType == '2' ? $t('weekDay.date') : (scope.row.customType == '1' ? $t('tuPian') : $t('wenBen'))}}
  20. </template>
  21. </el-table-column>
  22. <el-table-column :label="$t('operation')" width="280">
  23. <template slot-scope="scope">
  24. <el-button size="mini" type="primary" @click="editor(scope.row, $t('bianJiBiaoDanZiDuan'))">{{ $t('bian-ji') }}</el-button>
  25. <el-button size="mini" type="danger" @click="deteles(scope.row)">{{ $t('btn.delete') }}</el-button>
  26. </template>
  27. </el-table-column>
  28. </el-table>
  29. </div>
  30. <!-- 弹窗 -->
  31. <el-dialog :title="titleTex" :visible.sync="dialogVisible" width="400px" :before-close="handleClose">
  32. <div>
  33. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="80px" class="demo-ruleForm">
  34. <el-form-item :label="$t('types')">
  35. <el-radio-group v-model="ruleForm.customType">
  36. <el-radio-button label="0">{{ $t('wenBen') }}</el-radio-button>
  37. <el-radio-button label="1">{{ $t('tuPian') }}</el-radio-button>
  38. <el-radio-button label="2">{{ $t('weekDay.date') }}</el-radio-button>
  39. </el-radio-group>
  40. </el-form-item>
  41. <el-form-item :label="$t('names')" prop="customName">
  42. <el-input :placeholder="$t('qingShuRuZiDingYiMingCheng')" v-model.trim="ruleForm.customName" clearable></el-input>
  43. </el-form-item>
  44. </el-form>
  45. </div>
  46. <span slot="footer" class="dialog-footer">
  47. <el-button @click="dialogVisible = false">{{ $t('quXiao') }}</el-button>
  48. <el-button type="primary" @click="determine('ruleForm')" v-loading="listLoading">{{ $t('queDing') }}</el-button>
  49. </span>
  50. </el-dialog>
  51. </div>
  52. </template>
  53. <script>
  54. export default {
  55. props: {},
  56. components: {},
  57. data() {
  58. return {
  59. heightDoms: document.documentElement.clientHeight - 130,
  60. titleTex: this.$t('tianJiaBiaoDanZiDuan'),
  61. dialogVisible: false,
  62. ruleForm: {
  63. id: '',
  64. companyId: '',
  65. customName: '',
  66. customType: '0'
  67. },
  68. rules: {customName: [{required: true, message: this.$t('qingShuRuZiDingYiMingCheng'), trigger: 'blur'}]},
  69. listLoading: false,
  70. user: JSON.parse(sessionStorage.getItem("user")),
  71. dataList: []
  72. };
  73. },
  74. computed: {},
  75. watch: {},
  76. created() {},
  77. mounted() {
  78. this.getObtain()
  79. },
  80. methods: {
  81. getObtain() {
  82. this.listLoading = true
  83. this.http.post('/project-custom/getProjectCustom', this.ruleForm,
  84. res => {
  85. this.listLoading = false
  86. if(res.code == 'ok') {
  87. this.dataList = res.data
  88. } else {
  89. this.$message({
  90. message: error,
  91. type: "error"
  92. });
  93. }
  94. },
  95. error => {
  96. this.listLoading = false;
  97. this.$message({
  98. message: error,
  99. type: "error"
  100. });
  101. });
  102. },
  103. addJa(tex) {
  104. if(this.dataList.length >= 10) {
  105. this.$message({
  106. message: this.$t('zuiDuoZhiNengCunZaiShiGeZiDingYiZiDuan'),
  107. type: 'warning'
  108. });
  109. return
  110. }
  111. if(this.$refs['ruleForm']) {
  112. this.$refs['ruleForm'].resetFields();
  113. }
  114. this.titleTex = tex
  115. this.ruleForm = {
  116. id: '',
  117. companyId: '',
  118. customName: '',
  119. customType: '0'
  120. },
  121. this.dialogVisible = true
  122. },
  123. editor(item, tex) {
  124. if(this.$refs['ruleForm']) {
  125. this.$refs['ruleForm'].resetFields();
  126. }
  127. this.titleTex = tex
  128. this.ruleForm = JSON.parse(JSON.stringify(item))
  129. this.dialogVisible = true
  130. },
  131. determine(formName) {
  132. this.$refs[formName].validate((valid) => {
  133. if (valid) {
  134. this.listLoading = true
  135. this.ruleForm.companyId = this.user.companyId
  136. this.http.post( '/project-custom/editProjectCustom', this.ruleForm,
  137. res => {
  138. this.listLoading = false
  139. if(res.code == 'ok') {
  140. this.$message({
  141. message: this.titleTex == this.$t('tianJiaBiaoDanZiDuan') ? this.$t('addsuccessful') : this.$t('editsuccess'),
  142. type: 'success'
  143. });
  144. this.dialogVisible = false
  145. this.getObtain()
  146. } else {
  147. this.$message({
  148. message: this.titleTex == this.$t('tianJiaBiaoDanZiDuan') ? this.$t('tianJiaShiBai') + res.msg : this.$t('bianJiShiBai') + res.msg,
  149. type: 'error'
  150. });
  151. }
  152. },
  153. error => {
  154. this.listLoading = false;
  155. this.$message({
  156. message: error,
  157. type: "error"
  158. });
  159. });
  160. } else {
  161. console.log('error submit!!');
  162. return false;
  163. }
  164. });
  165. },
  166. deteles(item) {
  167. this.http.post( '/project-custom/delete', {
  168. id: item.id
  169. },
  170. res => {
  171. if(res.code == 'ok') {
  172. this.$message({
  173. message: this.$t('message.successfullyDeleted'),
  174. type: 'success'
  175. });
  176. this.getObtain()
  177. } else {
  178. this.$message({
  179. message: this.$t('shanChuShiBai') + res.msg,
  180. type: 'error'
  181. });
  182. }
  183. },
  184. error => {
  185. this.$message({
  186. message: error,
  187. type: "error"
  188. });
  189. });
  190. }
  191. },
  192. };
  193. </script>
  194. <style scoped lang="scss">
  195. @import "../../assets/scss/handle";
  196. .themeFontColor {
  197. @include font_color("color");
  198. }
  199. .infrastructures {
  200. color: #666;
  201. .til {
  202. display: flex;
  203. justify-content: space-between;
  204. line-height: 0;
  205. background: #f2f2f2;
  206. padding: 10px 25px 10px 25px;
  207. align-items: center;
  208. p {
  209. font-size: 14px;
  210. i {
  211. display: inline-block;
  212. margin-right: 5px;
  213. }
  214. }
  215. }
  216. .tabl {
  217. padding-left: 15px;
  218. box-sizing: border-box;
  219. }
  220. }
  221. </style>