e6490ecdea5d7e34b4d332ab9d74a1d32b65fd61.svn-base 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <a-modal
  3. :title="title"
  4. :width="1200"
  5. :visible="visible"
  6. :confirmLoading="confirmLoading"
  7. @ok="handleOk"
  8. @cancel="handleCancel">
  9. <a-spin :spinning="confirmLoading">
  10. <a-form-model ref="form" :label-col="labelCol" :wrapper-col="wrapperCol" :model="orderMainModel" :rules="validatorRules">
  11. <!-- 主表单区域 -->
  12. <a-row class="form-row" :gutter="16">
  13. <a-col :lg="8">
  14. <a-form-model-item label="订单号" required prop="orderCode">
  15. <a-input v-model="orderMainModel.orderCode" placeholder="请输入订单号"/>
  16. </a-form-model-item>
  17. </a-col>
  18. <a-col :lg="8">
  19. <a-form-model-item label="订单类型" prop="ctype">
  20. <a-select placeholder="请选择订单类型" v-model="orderMainModel.ctype" >
  21. <a-select-option value="1">国内订单</a-select-option>
  22. <a-select-option value="2">国际订单</a-select-option>
  23. </a-select>
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :lg="8">
  27. <a-form-model-item label="订单日期" prop="orderDate">
  28. <a-date-picker showTime valueFormat="YYYY-MM-DD HH:mm:ss" v-model="orderMainModel.orderDate"/>
  29. </a-form-model-item>
  30. </a-col>
  31. </a-row>
  32. <a-row class="form-row" :gutter="16">
  33. <a-col :lg="8">
  34. <a-form-model-item label="订单金额" prop="orderMoney">
  35. <a-input-number style="width: 200px" v-model="orderMainModel.orderMoney"/>
  36. </a-form-model-item>
  37. </a-col>
  38. <a-col :lg="8">
  39. <a-form-model-item label="订单备注" prop="content">
  40. <a-input placeholder="请输入订单备注" v-model="orderMainModel.content" />
  41. </a-form-model-item>
  42. </a-col>
  43. </a-row>
  44. <!-- 子表单区域 -->
  45. <a-tabs defaultActiveKey="1" >
  46. <a-tab-pane tab="客户信息" key="1">
  47. <div>
  48. <a-row type="flex" style="margin-bottom:10px" :gutter="16">
  49. <a-col :span="5">客户名</a-col>
  50. <a-col :span="5">性别</a-col>
  51. <a-col :span="6">身份证号码</a-col>
  52. <a-col :span="6">手机号</a-col>
  53. <a-col :span="2">操作</a-col>
  54. </a-row>
  55. <a-row type="flex" style="margin-bottom:10px" :gutter="16" v-for="(item, index) in orderMainModel.jeecgOrderCustomerList" :key="index">
  56. <a-col :span="6" style="display: none">
  57. <a-form-model-item>
  58. <a-input placeholder="id" v-model="item.id" />
  59. </a-form-model-item>
  60. </a-col>
  61. <a-col :span="5">
  62. <a-form-model-item>
  63. <a-input placeholder="客户名" v-model="item.name" />
  64. </a-form-model-item>
  65. </a-col>
  66. <a-col :span="5">
  67. <a-form-model-item>
  68. <a-select placeholder="性别" v-model="item.sex" >
  69. <a-select-option value="1">男</a-select-option>
  70. <a-select-option value="2">女</a-select-option>
  71. </a-select>
  72. </a-form-model-item>
  73. </a-col>
  74. <a-col :span="6">
  75. <a-form-model-item :prop="'jeecgOrderCustomerList.' + index + '.idcard'" :rules="[{required: true,message: '请输入身份证号',trigger: 'blur'},{ pattern: rules.IDCard, message: '身份证号格式不对!' }]">
  76. <a-input placeholder="身份证号" v-model="item.idcard" />
  77. </a-form-model-item>
  78. </a-col>
  79. <a-col :span="6">
  80. <a-form-model-item :prop="'jeecgOrderCustomerList.' + index + '.telphone'" :rules="rules.mobile">
  81. <a-input placeholder="手机号" v-model="item.telphone"/>
  82. </a-form-model-item>
  83. </a-col>
  84. <a-col :span="2">
  85. <a-form-model-item>
  86. <a-icon type="minus-circle" @click="delRowCustom(index)" style="fontSize :20px"/>
  87. </a-form-model-item>
  88. </a-col>
  89. </a-row>
  90. <a-button type="dashed" style="width: 98%;margin-top: 10px" @click="addRowCustom">
  91. <a-icon type="plus" /> 添加客户信息
  92. </a-button>
  93. </div>
  94. </a-tab-pane>
  95. <a-tab-pane tab="机票信息" key="2" forceRender>
  96. <div>
  97. <a-row type="flex" style="margin-bottom:10px" :gutter="16">
  98. <a-col :span="6">航班号</a-col>
  99. <a-col :span="6">航班时间</a-col>
  100. <a-col :span="6">操作</a-col>
  101. </a-row>
  102. <a-row type="flex" style="margin-bottom:10px" :gutter="16" v-for="(item, index) in orderMainModel.jeecgOrderTicketList" :key="index">
  103. <a-col :span="6" style="display: none">
  104. <a-form-model-item>
  105. <a-input placeholder="id" v-model="item.id" />
  106. </a-form-model-item>
  107. </a-col>
  108. <a-col :span="6">
  109. <a-form-model-item :prop="'jeecgOrderTicketList.' + index + '.ticketCode'" :rules="{required: true,message: '请输入航班号',trigger: 'blur'}">
  110. <a-input placeholder="航班号" v-model="item.ticketCode"/>
  111. </a-form-model-item>
  112. </a-col>
  113. <a-col :span="6">
  114. <a-form-model-item>
  115. <a-date-picker placeholder="航班时间" valueFormat="YYYY-MM-DD" v-model="item.tickectDate" />
  116. </a-form-model-item>
  117. </a-col>
  118. <a-col :span="6">
  119. <a-form-model-item>
  120. <a-icon type="minus-circle" @click="delRowTicket(index)" style="fontSize :20px"/>
  121. </a-form-model-item>
  122. </a-col>
  123. </a-row>
  124. <a-button type="dashed" style="width: 98%;margin-top: 10px" @click="addRowTicket">
  125. <a-icon type="plus" /> 添加机票信息
  126. </a-button>
  127. </div>
  128. </a-tab-pane>
  129. </a-tabs>
  130. </a-form-model>
  131. </a-spin>
  132. </a-modal>
  133. </template>
  134. <script>
  135. import { httpAction,getAction } from '@/api/manage'
  136. import JDate from '@/components/jeecg/JDate'
  137. export default {
  138. name: "JeecgOrderMainModal",
  139. components: {
  140. JDate
  141. },
  142. data () {
  143. return {
  144. title:"操作",
  145. visible: false,
  146. orderMainModel: {
  147. jeecgOrderCustomerList: [{}],
  148. jeecgOrderTicketList: [{}]
  149. },
  150. labelCol: {
  151. xs: { span: 24 },
  152. sm: { span: 5 },
  153. },
  154. wrapperCol: {
  155. xs: { span: 24 },
  156. sm: { span: 16 },
  157. },
  158. confirmLoading: false,
  159. validatorRules:{
  160. orderCode: [
  161. { required: true, message: '订单号不能为空', trigger: 'blur' }
  162. ]
  163. },
  164. url: {
  165. add: "/test/jeecgOrderMain/add",
  166. edit: "/test/jeecgOrderMain/edit",
  167. orderCustomerList: "/test/jeecgOrderMain/queryOrderCustomerListByMainId",
  168. orderTicketList: "/test/jeecgOrderMain/queryOrderTicketListByMainId",
  169. },
  170. }
  171. },
  172. created () {
  173. },
  174. methods: {
  175. add () {
  176. this.edit({});
  177. },
  178. edit (record) {
  179. this.orderMainModel = Object.assign({
  180. jeecgOrderCustomerList: [{}],
  181. jeecgOrderTicketList: [{}]
  182. }, record);
  183. //--------------------------------------------------------
  184. //初始化明细表数据
  185. console.log(this.orderMainModel.id)
  186. if(this.orderMainModel.id){
  187. let params = {id:this.orderMainModel.id}
  188. //初始化订单机票列表
  189. getAction(this.url.orderCustomerList,params).then((res)=>{
  190. if(res.success){
  191. this.orderMainModel.jeecgOrderCustomerList = res.result;
  192. this.$forceUpdate()
  193. }
  194. })
  195. //初始化订单客户列表
  196. getAction(this.url.orderTicketList,params).then((res)=>{
  197. if(res.success){
  198. this.orderMainModel.jeecgOrderTicketList = res.result;
  199. this.$forceUpdate()
  200. }
  201. })
  202. }
  203. this.visible = true;
  204. },
  205. close () {
  206. this.$emit('close');
  207. this.visible = false;
  208. },
  209. handleOk () {
  210. const that = this;
  211. // 触发表单验证
  212. this.$refs.form.validate(valid => {
  213. if (valid) {
  214. that.confirmLoading = true;
  215. let httpurl = '';
  216. let method = '';
  217. if(!this.orderMainModel.id){
  218. httpurl+=this.url.add;
  219. method = 'post';
  220. }else{
  221. httpurl+=this.url.edit;
  222. //method = 'put';
  223. method = 'post';
  224. }
  225. httpAction(httpurl,this.orderMainModel,method).then((res)=>{
  226. if(res.success){
  227. that.$message.success(res.message);
  228. that.$emit('ok');
  229. }else{
  230. that.$message.warning(res.message);
  231. }
  232. }).finally(() => {
  233. that.confirmLoading = false;
  234. that.close();
  235. })
  236. }
  237. })
  238. },
  239. handleCancel () {
  240. this.close()
  241. },
  242. addRowCustom () {
  243. this.orderMainModel.jeecgOrderCustomerList.push({});
  244. this.$forceUpdate();
  245. },
  246. delRowCustom (index) {
  247. console.log(index)
  248. let all = this.orderMainModel
  249. all['jeecgOrderCustomerList'].splice(index,1);
  250. this.orderMainModel.jeecgOrderCustomerList.splice(index,1);
  251. this.$forceUpdate();
  252. },
  253. addRowTicket () {
  254. this.orderMainModel.jeecgOrderTicketList.push({});
  255. console.log(this.orderMainModel.jeecgOrderTicketList)
  256. this.$forceUpdate();
  257. },
  258. delRowTicket (index) {
  259. console.log(index)
  260. let all = this.orderMainModel
  261. all['jeecgOrderTicketList'].splice(index,1);
  262. this.orderMainModel.jeecgOrderTicketList.splice(index,1);
  263. this.$forceUpdate();
  264. },
  265. }
  266. }
  267. </script>
  268. <style scoped>
  269. .ant-btn {
  270. padding: 0 10px;
  271. margin-left: 3px;
  272. }
  273. .ant-form-item-control {
  274. line-height: 0px;
  275. }
  276. /** 主表单行间距 */
  277. .ant-form .ant-form-item {
  278. margin-bottom: 10px;
  279. }
  280. /** Tab页面行间距 */
  281. .ant-tabs-content .ant-form-item {
  282. margin-bottom: 0px;
  283. }
  284. </style>