InsCountry.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <div class="InsCountry-all">
  3. <el-dialog width="830px" class="InsCountry-dialog" title="新增编辑" :visible.sync="dialogTableVisible" :close-on-click-modal="false">
  4. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="110px" class="demo-ruleForm">
  5. <div class="InsCountry-form">
  6. <el-form-item label="国家名称" prop="countryName">
  7. <el-input v-model="ruleForm.countryName"></el-input>
  8. </el-form-item>
  9. <el-form-item label="是否为申根国" prop="isSchengen">
  10. <el-radio-group v-model="ruleForm.isSchengen">
  11. <el-radio label="是申根国"></el-radio>
  12. <el-radio label="不是申根国"></el-radio>
  13. </el-radio-group>
  14. </el-form-item>
  15. <el-form-item label="保险费用" prop="cost">
  16. <el-input-number class="append_unit" data-unit="CNY" :controls="false" v-model="ruleForm.cost" :precision="2">
  17. </el-input-number>
  18. </el-form-item>
  19. <el-form-item style="width:100%;" label="备注">
  20. <el-input type="textarea" :rows="2" v-model="ruleForm.remark"></el-input>
  21. </el-form-item>
  22. </div>
  23. <el-form-item style="text-align: right;width:100%;">
  24. <el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
  25. <el-button @click="resetForm('ruleForm')">重置</el-button>
  26. <el-button @click="dialogTableVisible=false">取消</el-button>
  27. </el-form-item>
  28. </el-form>
  29. </el-dialog>
  30. <div>国家保险标准</div>
  31. <div class="InsCountry-search">
  32. <div>
  33. <el-input clearable size="small" style="width:250px;" v-model="searchinput" placeholder="请输入国家"></el-input>
  34. <el-button @click="InsuranceCostPageItem" size="small" type="primary">查询</el-button>
  35. </div>
  36. <el-button @click="InsCountryadd" size="small" type="primary">新增</el-button>
  37. </div>
  38. <div class="InsCountry-table">
  39. <el-table
  40. :data="tableData"
  41. border
  42. style="width: 100%">
  43. <el-table-column
  44. prop="countryName"
  45. label="国家"
  46. width="180">
  47. </el-table-column>
  48. <el-table-column
  49. prop="cost"
  50. label="金额"
  51. width="180">
  52. <template slot-scope="scope">
  53. {{ townum(scope.row.cost) }}
  54. </template>
  55. </el-table-column>
  56. <el-table-column
  57. prop="createTime"
  58. label="更新时间"
  59. width="180">
  60. </el-table-column>
  61. <el-table-column
  62. prop="createUserName"
  63. label="录入人"
  64. width="180">
  65. </el-table-column>
  66. <el-table-column
  67. prop="remark"
  68. label="备注">
  69. </el-table-column>
  70. <el-table-column
  71. label="操作"
  72. width="180">
  73. <template slot-scope="scope">
  74. <el-button size="mini" @click="upDate(scope.row)">编辑</el-button>
  75. <el-button size="mini" type="danger" @click="del(scope.row)">删除</el-button>
  76. </template>
  77. </el-table-column>
  78. </el-table>
  79. <div class="block">
  80. <el-pagination
  81. @size-change="handleSizeChange"
  82. @current-change="handleCurrentChange"
  83. :current-page="currentPage"
  84. :page-sizes="[10,14, 15, 20, 30]"
  85. :page-size="pagesize"
  86. layout="total, sizes, prev, pager, next, jumper"
  87. :total="total">
  88. </el-pagination>
  89. </div>
  90. </div>
  91. </div>
  92. </template>
  93. <script>
  94. export default {
  95. data() {
  96. return {
  97. token:'',
  98. userid:'',
  99. tableData:[],
  100. searchinput:'',
  101. currentPage:1,
  102. pagesize:14,
  103. total:0,
  104. dialogTableVisible:false,
  105. ruleForm: {
  106. id:'',
  107. countryName:'',
  108. cost:0,
  109. isSchengen:'',
  110. remark: '',
  111. },
  112. rules: {
  113. countryName: [
  114. { required: true, message: '请输入', trigger: 'blur' },
  115. ],
  116. cost: [
  117. { required: true, message: '请输入', trigger: 'blur' }
  118. ],
  119. isSchengen: [
  120. { required: true, message: '请选择', trigger: 'change' }
  121. ],
  122. },
  123. }
  124. },
  125. methods:{
  126. //保留两位小数
  127. townum(val){
  128. val=Number(val);
  129. return val.toFixed(2);
  130. },
  131. handleSizeChange(val) {
  132. this.currentPage=1;
  133. this.pagesize=val;
  134. this.InsuranceCostPageItem();
  135. },
  136. handleCurrentChange(val) {
  137. this.currentPage=val;
  138. this.InsuranceCostPageItem();
  139. },
  140. //获取表格
  141. InsuranceCostPageItem(){
  142. var url = "/api/Resource/InsuranceCostPageItem"
  143. var that = this
  144. this.$axios({
  145. method: 'post',
  146. url: url,
  147. headers: {
  148. Authorization: 'Bearer '
  149. },
  150. data:{
  151. portType:1,
  152. pageIndex:that.currentPage,
  153. pageSize:that.pagesize,
  154. search:that.searchinput,
  155. }
  156. }).then(function (res) {
  157. if(res.data.code==200){
  158. that.tableData=res.data.data;
  159. that.total=res.data.count;
  160. }else{
  161. that.$message({
  162. message: '加载失败!原因:'+res.data.msg,
  163. type: 'warning'
  164. });
  165. }
  166. })
  167. },
  168. InsCountryadd(){
  169. this.dialogTableVisible=true;
  170. this.ruleForm={
  171. id:'',
  172. countryName:'',
  173. cost:0,
  174. isSchengen:'',
  175. remark: '',
  176. }
  177. },
  178. //编辑
  179. upDate(val){
  180. this.InsCountryadd();
  181. this.InsuranceCostInfo(val.id)
  182. },
  183. //获取详情
  184. InsuranceCostInfo(val){
  185. var url = "/api/Resource/InsuranceCostInfo"
  186. var that = this
  187. this.$axios({
  188. method: 'post',
  189. url: url,
  190. headers: {
  191. Authorization: 'Bearer '
  192. },
  193. data:{
  194. portType:1,
  195. id:val,
  196. }
  197. }).then(function (res) {
  198. if(res.data.code==200){
  199. let infobxbz=res.data.data
  200. that.ruleForm.id=infobxbz.id;
  201. that.ruleForm.countryName=infobxbz.countryName;
  202. that.ruleForm.cost=infobxbz.cost;
  203. that.ruleForm.isSchengen=infobxbz.isSchengen==1?'是申根国':'不是申根国';
  204. that.ruleForm.remark=infobxbz.remark;
  205. }else{
  206. that.$message({
  207. message: '加载失败!原因:'+res.data.msg,
  208. type: 'warning'
  209. });
  210. }
  211. })
  212. },
  213. del(row) {
  214. this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
  215. confirmButtonText: '确定',
  216. cancelButtonText: '取消',
  217. type: 'warning'
  218. }).then(() => {
  219. var url = "/api/Resource/InsuranceCostSoftDel"
  220. var that = this
  221. this.$axios({
  222. method: 'post',
  223. url: url,
  224. headers: {
  225. Authorization: 'Bearer '
  226. },
  227. data: {
  228. portType:1,
  229. currUserId: that.userid,
  230. id: row.id,
  231. }
  232. }).then(function (res) {
  233. if (res.data.code == 200) {
  234. that.dialogTableVisible=false;
  235. that.$message({
  236. message:res.data.msg,
  237. type: 'success'
  238. });
  239. that.InsuranceCostPageItem();
  240. } else {
  241. that.$message.error(res.data.msg);
  242. }
  243. }).catch(function (error) {
  244. that.$message.error("出错!请联系信息部");
  245. });
  246. }).catch(() => {
  247. this.$message({
  248. type: 'info',
  249. message: '操作已取消!'
  250. });
  251. });
  252. },
  253. //新增api
  254. InsuranceCostOp(){
  255. var url = "/api/Resource/InsuranceCostOp"
  256. var that = this
  257. this.$axios({
  258. method: 'post',
  259. url: url,
  260. headers: {
  261. Authorization: 'Bearer '
  262. },
  263. data:{
  264. portType:1,
  265. id:that.ruleForm.id==''?0:that.ruleForm.id,
  266. currUserId:that.userid,
  267. isSchengen:that.ruleForm.isSchengen=='是申根国'?1:0,
  268. countryName:that.ruleForm.countryName,
  269. cost:that.ruleForm.cost,
  270. remark:that.ruleForm.remark,
  271. }
  272. }).then(function (res) {
  273. if(res.data.code==200){
  274. that.dialogTableVisible=false
  275. that.$message({
  276. type: 'success',
  277. message: res.data.msg
  278. });
  279. that.InsuranceCostPageItem();
  280. }else{
  281. that.$message({
  282. message: '加载失败!原因:'+res.data.msg,
  283. type: 'warning'
  284. });
  285. }
  286. })
  287. },
  288. submitForm(formName) {
  289. this.$refs[formName].validate((valid) => {
  290. if (valid) {
  291. this.InsuranceCostOp();
  292. } else {
  293. console.log('error submit!!');
  294. return false;
  295. }
  296. });
  297. },
  298. resetForm(formName) {
  299. this.$refs[formName].resetFields();
  300. },
  301. },
  302. mounted(){
  303. this.token = JSON.parse(localStorage.getItem('userinif')).token;
  304. this.userid=JSON.parse(localStorage.getItem('userinif')).userInfo.userId;
  305. this.InsuranceCostPageItem();
  306. },
  307. }
  308. </script>
  309. <style>
  310. .InsCountry-all {
  311. background-color: #fff;
  312. padding: 10px;
  313. box-shadow: 0 0 5px #0005;
  314. border-radius: 10px;
  315. min-height: 830px;
  316. }
  317. .InsCountry-search{
  318. display: flex;
  319. justify-content: space-between;
  320. margin: 10px 0 ;
  321. }
  322. .InsCountry-table .block{
  323. text-align: center;
  324. margin-top: 15px;
  325. }
  326. .InsCountry-dialog .el-form-item{
  327. width: 395px;
  328. }
  329. .InsCountry-dialog .el-select,.el-input,.el-input-number{
  330. width: 100%;
  331. }
  332. .InsCountry-form{
  333. display: flex;
  334. flex-wrap:wrap ;
  335. }
  336. </style>