9eb32078e6128df4c2831c9ca35df276b55ad183.svn-base 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <a-modal
  3. :title="title"
  4. :width="800"
  5. :visible="visible"
  6. :confirmLoading="confirmLoading"
  7. :okButtonProps="{ props: {disabled: disableSubmit} }"
  8. @ok="handleOk"
  9. @cancel="handleCancel"
  10. cancelText="关闭">
  11. <!-- 编辑 -->
  12. <a-spin :spinning="confirmLoading" v-if="editStatus">
  13. <a-form-model ref="form" :model="model" :rules="validatorRules">
  14. <a-form-model-item
  15. :labelCol="labelCol"
  16. :wrapperCol="wrapperCol"
  17. label="客户姓名"
  18. prop="name"
  19. required
  20. hasFeedback>
  21. <a-input placeholder="请输入客户姓名" v-model="model.name" :readOnly="disableSubmit"/>
  22. </a-form-model-item>
  23. <a-form-model-item
  24. :labelCol="labelCol"
  25. :wrapperCol="wrapperCol"
  26. label="性别"
  27. hasFeedback>
  28. <a-select v-model="model.sex" placeholder="请选择性别">
  29. <a-select-option value="1">男性</a-select-option>
  30. <a-select-option value="2">女性</a-select-option>
  31. </a-select>
  32. </a-form-model-item>
  33. <a-form-model-item
  34. :labelCol="labelCol"
  35. :wrapperCol="wrapperCol"
  36. label="身份证号码"
  37. prop="idcard"
  38. hasFeedback>
  39. <a-input placeholder="请输入身份证号码" v-model="model.idcard" :readOnly="disableSubmit"/>
  40. </a-form-model-item>
  41. <a-form-model-item
  42. :labelCol="labelCol"
  43. :wrapperCol="wrapperCol"
  44. label="身份证扫描件"
  45. hasFeedback>
  46. <j-image-upload text="上传" v-model="fileList" :isMultiple="true"></j-image-upload>
  47. </a-form-model-item>
  48. <a-form-model-item
  49. :labelCol="labelCol"
  50. :wrapperCol="wrapperCol"
  51. label="联系方式"
  52. prop="telphone"
  53. hasFeedback>
  54. <a-input v-model="model.telphone" :readOnly="disableSubmit"/>
  55. </a-form-model-item>
  56. <a-form-model-item
  57. :labelCol="labelCol"
  58. :wrapperCol="wrapperCol"
  59. label="订单号码"
  60. :hidden="hiding"
  61. hasFeedback>
  62. <a-input v-model="model.orderId" disabled="disabled"/>
  63. </a-form-model-item>
  64. </a-form-model>
  65. </a-spin>
  66. </a-modal>
  67. </template>
  68. <script>
  69. import {httpAction} from '@/api/manage'
  70. import Vue from 'vue'
  71. import {ACCESS_TOKEN} from "@/store/mutation-types"
  72. import JImageUpload from '../../../../components/jeecg/JImageUpload'
  73. export default {
  74. name: "JeecgOrderCustomerModal",
  75. components: { JImageUpload },
  76. data() {
  77. return {
  78. title: "操作",
  79. visible: false,
  80. model: {},
  81. labelCol: {
  82. xs: {span: 24},
  83. sm: {span: 5},
  84. },
  85. wrapperCol: {
  86. xs: {span: 24},
  87. sm: {span: 16},
  88. },
  89. fileList: [],
  90. disableSubmit: false,
  91. selectedRowKeys: [],
  92. orderId: "",
  93. hiding: false,
  94. headers: {},
  95. picUrl: "",
  96. picArray:[],
  97. previewVisible: false,
  98. previewImage: '',
  99. addStatus: false,
  100. editStatus: false,
  101. confirmLoading: false,
  102. url: {
  103. add: "/test/order/addCustomer",
  104. edit: "/test/order/editCustomer",
  105. fileUpload: window._CONFIG['domianURL'] + "/sys/common/upload",
  106. getOrderCustomerList: "/test/order/listOrderCustomerByMainId",
  107. },
  108. validatorRules: {
  109. name :[{required: true, message: '请输入客户姓名!'}],
  110. telphone: [{validator: this.validateMobile}],
  111. idcard: [{validator: this.validateIdCard}]
  112. },
  113. }
  114. },
  115. computed: {
  116. uploadAction: function () {
  117. return this.url.fileUpload;
  118. }
  119. },
  120. created() {
  121. const token = Vue.ls.get(ACCESS_TOKEN);
  122. this.headers = {"X-Access-Token": token}
  123. },
  124. methods: {
  125. add(orderId) {
  126. this.hiding = true;
  127. if (orderId) {
  128. this.edit({orderId}, '');
  129. } else {
  130. this.$message.warning("请选择一个客户信息");
  131. }
  132. },
  133. detail(record) {
  134. this.edit(record, 'd');
  135. },
  136. edit(record, v) {
  137. if (v == 'e') {
  138. this.hiding = false;
  139. this.disableSubmit = false;
  140. } else if (v == 'd') {
  141. this.hiding = false;
  142. this.disableSubmit = true;
  143. } else {
  144. this.hiding = true;
  145. this.disableSubmit = false;
  146. }
  147. this.model = Object.assign({}, record);
  148. if (record.id) {
  149. this.hiding = false;
  150. this.addStatus = false;
  151. this.editStatus = true;
  152. setTimeout(() => {
  153. this.fileList = record.idcardPic
  154. }, 5)
  155. } else {
  156. this.addStatus = false;
  157. this.editStatus = true;
  158. }
  159. this.visible = true;
  160. },
  161. close() {
  162. this.$emit('close');
  163. this.visible = false;
  164. this.picUrl = "";
  165. this.fileList=[];
  166. this.$refs.form.resetFields();
  167. },
  168. handleOk() {
  169. const that = this;
  170. // 触发表单验证
  171. this.$refs.form.validate(valid => {
  172. if (valid) {
  173. that.confirmLoading = true;
  174. let httpurl = '';
  175. let method = '';
  176. if (!this.model.id) {
  177. httpurl += this.url.add;
  178. method = 'post';
  179. } else {
  180. httpurl += this.url.edit;
  181. //method = 'put';
  182. method = 'post';
  183. }
  184. let formData = Object.assign({}, this.model);
  185. if(this.fileList != '') {
  186. formData.idcardPic = this.fileList;
  187. }else{
  188. formData.idcardPic = '';
  189. }
  190. httpAction(httpurl, formData, method).then((res) => {
  191. if (res.success) {
  192. that.$message.success(res.message);
  193. that.$emit('ok');
  194. } else {
  195. that.$message.warning(res.message);
  196. }
  197. }).finally(() => {
  198. that.confirmLoading = false;
  199. that.close();
  200. })
  201. }else{
  202. return false;
  203. }
  204. })
  205. },
  206. handleCancel() {
  207. this.close();
  208. },
  209. validateMobile(rule, value, callback) {
  210. if (!value || new RegExp(/^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/).test(value)) {
  211. callback();
  212. } else {
  213. callback("您的手机号码格式不正确!");
  214. }
  215. },
  216. validateIdCard(rule, value, callback) {
  217. if (!value || new RegExp(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/).test(value)) {
  218. callback();
  219. } else {
  220. callback("您的身份证号码格式不正确!");
  221. }
  222. },
  223. }
  224. }
  225. </script>
  226. <style scoped>
  227. /* tile uploaded pictures */
  228. .upload-list-inline > > > .ant-upload-list-item {
  229. float: left;
  230. width: 200px;
  231. margin-right: 8px;
  232. }
  233. .upload-list-inline > > > .ant-upload-animate-enter {
  234. animation-name: uploadAnimateInlineIn;
  235. }
  236. .upload-list-inline > > > .ant-upload-animate-leave {
  237. animation-name: uploadAnimateInlineOut;
  238. }
  239. </style>