血透系统PC前端

City.vue 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <div class="main-contain">
  3. <div>
  4. <div class="titleOne">
  5. 质控平台的上报对接,是为了解决手工录入的效率和易出错的问题,对接涉及各种技术,请勿随意配置,联系酷医云客服协助处理。
  6. </div>
  7. <div class="titleOne">微信:kuyicloud 电话:18682074632</div>
  8. <div class="formBox">
  9. <el-form
  10. :model="form"
  11. :rules="rules"
  12. ref="ruleForm"
  13. label-width="120px"
  14. class="demo-ruleForm"
  15. style="text-align: center"
  16. >
  17. <el-form-item label="省" prop="province">
  18. <el-select
  19. v-model="form.province"
  20. clearable
  21. filterable
  22. placeholder="请选择"
  23. @change="changeProvince"
  24. >
  25. <el-option
  26. v-for="item in provinces"
  27. :key="item.id"
  28. :label="item.name"
  29. :value="item.id"
  30. >
  31. </el-option>
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item label="市" prop="city">
  35. <el-select
  36. v-model="form.city"
  37. clearable
  38. filterable
  39. placeholder="请选择"
  40. @change="changeCity"
  41. >
  42. <el-option
  43. v-for="item in citys"
  44. :key="item.id"
  45. :label="item.name"
  46. :value="item.id"
  47. >
  48. </el-option>
  49. </el-select>
  50. </el-form-item>
  51. <el-form-item label="网关地址" prop="gateway_address">
  52. <el-input v-model="form.gateway_address"></el-input>
  53. </el-form-item>
  54. <el-form-item label="AppID" prop="app_id">
  55. <el-input v-model="form.app_id"></el-input>
  56. </el-form-item>
  57. <el-form-item label="密钥" prop="key">
  58. <el-input v-model="form.key"></el-input>
  59. </el-form-item>
  60. <el-form-item label="自动上传周期" prop="time_type">
  61. <el-radio-group v-model="form.time_type">
  62. <el-radio label="1">一周</el-radio>
  63. <el-radio label="2">二周</el-radio>
  64. <el-radio label="3">一个月</el-radio>
  65. <el-radio label="4">三个月</el-radio>
  66. </el-radio-group>
  67. </el-form-item>
  68. <el-form-item>
  69. <el-button
  70. type="primary"
  71. @click="submitForm('ruleForm')"
  72. class="changeLeft"
  73. >保存</el-button
  74. >
  75. </el-form-item>
  76. </el-form>
  77. </div>
  78. </div>
  79. </div>
  80. </template>
  81. <script>
  82. import { GetDistrictsByUpid } from "@/api/district";
  83. import {
  84. getConfig,
  85. postConfig,
  86. postModifyConfig,
  87. getIsDocking
  88. } from "@/api/config";
  89. export default {
  90. name: "City",
  91. data() {
  92. return {
  93. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  94. provinces: [],
  95. citys: [],
  96. form: {
  97. id: 0,
  98. province: "",
  99. city: "",
  100. gateway_address: "",
  101. app_id: "",
  102. key: "",
  103. time_type: "",
  104. config_type: 3
  105. },
  106. rules: {
  107. gateway_address: [
  108. { required: true, message: "请输入网关地址", trigger: "blur" }
  109. ],
  110. province: [
  111. { required: true, message: "请选择省份", trigger: "change" }
  112. ],
  113. city: [{ required: true, message: "请选择城市", trigger: "change" }],
  114. app_id: [{ required: true, message: "请输入AppID", trigger: "blur" }],
  115. key: [{ required: true, message: "请输入密钥", trigger: "blur" }],
  116. time_type: [
  117. { required: true, message: "请选择自动上传周期", trigger: "change" }
  118. ]
  119. }
  120. };
  121. },
  122. created() {
  123. this.getDistricts();
  124. this.getConfig();
  125. },
  126. methods: {
  127. submitForm: function(formName) {
  128. this.$refs[formName].validate(valid => {
  129. if (valid) {
  130. if (this.form.id == 0) {
  131. postConfig(this.form)
  132. .then(response => {
  133. var res = response.data;
  134. console.log(res);
  135. if (res.state == 1) {
  136. this.config = res.data.config;
  137. this.form.id = this.config.id;
  138. this.form.gateway_address = this.config.gateway_address;
  139. this.form.app_id = this.config.app_id;
  140. this.form.key = this.config.key;
  141. this.form.province = this.config.province_id;
  142. this.form.time_type = this.config.time_quantum;
  143. this.$message.success("提交成功");
  144. } else {
  145. this.$message.error(res.msg);
  146. }
  147. })
  148. .catch(e => {});
  149. } else {
  150. postModifyConfig(this.form)
  151. .then(response => {
  152. var res = response.data;
  153. if (res.state == 1) {
  154. this.config = res.data.config;
  155. this.form.id = this.config.id;
  156. this.form.gateway_address = this.config.gateway_address;
  157. this.form.app_id = this.config.app_id;
  158. this.form.key = this.config.key;
  159. this.form.province = this.config.province_id;
  160. this.form.time_type = this.config.time_quantum;
  161. this.$message.success("修改成功");
  162. } else {
  163. this.$message.error(res.msg);
  164. }
  165. })
  166. .catch(e => {});
  167. }
  168. } else {
  169. return false;
  170. }
  171. });
  172. },
  173. getDistricts: function() {
  174. GetDistrictsByUpid({ id: 0 })
  175. .then(response => {
  176. var res = response.data;
  177. if (res.state === 1) {
  178. this.provinces = res.data.citys;
  179. }
  180. })
  181. .catch(e => {});
  182. },
  183. getConfig: function() {
  184. getConfig({ config_type: 3 })
  185. .then(response => {
  186. var res = response.data;
  187. if (res.state === 1) {
  188. this.config = res.data.config;
  189. this.form.id = this.config.id;
  190. this.form.gateway_address = this.config.gateway_address;
  191. this.form.app_id = this.config.app_id;
  192. this.form.key = this.config.key;
  193. this.form.time = this.config.time_quantum;
  194. this.form.province = this.config.province_id;
  195. this.form.city = this.config.city_id;
  196. }
  197. })
  198. .catch(e => {});
  199. },
  200. changeProvince(id) {
  201. this.citys = [];
  202. this.form.district = id;
  203. var upid = parseInt(id);
  204. if (isNaN(upid) || upid <= 0) {
  205. return false;
  206. }
  207. GetDistrictsByUpid({ id: upid })
  208. .then(response => {
  209. var res = response.data;
  210. if (res.state === 1) {
  211. this.citys = res.data.citys;
  212. } else {
  213. this.$message.error(res.msg);
  214. }
  215. })
  216. .catch(e => {});
  217. },
  218. changeCity(id) {
  219. getIsDocking({ config_type: 2, province: this.form.province, city: id })
  220. .then(response => {
  221. var res = response.data;
  222. if (res.state == 1) {
  223. if (res.data.is_docking == 2) {
  224. this.$message.error("该地区尚未对接,请联系客服");
  225. this.form.province = "";
  226. this.form.city = "";
  227. } else {
  228. this.form.city = id;
  229. }
  230. } else {
  231. this.$message.error(res.msg);
  232. }
  233. })
  234. .catch(e => {});
  235. }
  236. }
  237. };
  238. </script>
  239. <style scoped>
  240. .changeLeft {
  241. margin-left: -254px !important;
  242. }
  243. .titleOne {
  244. line-height: 30px;
  245. margin: 0 auto;
  246. width: 100%;
  247. text-align: center;
  248. }
  249. .formBox {
  250. width: 46%;
  251. margin: 0 auto;
  252. }
  253. </style>
  254. <style lang="scss">
  255. .formBox {
  256. .el-select {
  257. width: 100%;
  258. }
  259. .el-input__inner {
  260. width: 90%;
  261. }
  262. }
  263. </style>