salesPersonForm.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <a-spin :spinning="confirmLoading">
  3. <j-form-container :disabled="formDisabled">
  4. <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
  5. <a-row>
  6. <a-col :span="24">
  7. <a-form-model-item label="编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="workNo">
  8. <a-input v-model="model.workNo" placeholder="请输入编号" ></a-input>
  9. </a-form-model-item>
  10. </a-col>
  11. <a-col :span="24">
  12. <a-form-model-item label="姓名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="name">
  13. <a-input v-model="model.name" placeholder="请输入姓名" ></a-input>
  14. </a-form-model-item>
  15. </a-col>
  16. <a-col :span="24">
  17. <a-form-model-item label="职务" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="postId">
  18. <!-- <a-input v-model="model.operatorId" placeholder="请选择职务" ></a-input>-->
  19. <a-select
  20. mode="multiple"
  21. v-model="model.postId"
  22. placeholder="请选择职务"
  23. :allowClear="true"
  24. >
  25. <a-select-option :value="item.id" v-for="(item,index) in postList" :key="index">{{ item.itemText }}</a-select-option>
  26. </a-select>
  27. </a-form-model-item>
  28. </a-col>
  29. <a-col :span="24">
  30. <a-form-model-item label="关联操作用户" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="operatorId">
  31. <!-- <a-input v-model="model.operatorId" placeholder="请选择关联操作用户" ></a-input>-->
  32. <a-select
  33. v-model="model.operatorId"
  34. placeholder="请选择关联操作用户"
  35. :allowClear="true"
  36. >
  37. <a-select-option :value="item.id" v-for="(item,index) in userList" :key="index">{{ item.name }}</a-select-option>
  38. </a-select>
  39. </a-form-model-item>
  40. </a-col>
  41. <a-col :span="24">
  42. <a-form-model-item label="联系电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="mobile">
  43. <a-input v-model="model.mobile" placeholder="请输入联系电话" ></a-input>
  44. </a-form-model-item>
  45. </a-col>
  46. <a-col :span="24">
  47. <a-form-model-item label="手机号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="phone">
  48. <a-input v-model="model.phone" placeholder="请输入手机号" ></a-input>
  49. </a-form-model-item>
  50. </a-col>
  51. <a-col :span="24">
  52. <a-form-model-item label="地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="address">
  53. <a-input v-model="model.address" placeholder="请输入地址" ></a-input>
  54. </a-form-model-item>
  55. </a-col>
  56. <a-col :span="24">
  57. <a-form-model-item label="备注信息" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remarks">
  58. <a-input v-model="model.remarks" placeholder="请输入备注信息" ></a-input>
  59. </a-form-model-item>
  60. </a-col>
  61. <a-col :span="24">
  62. <a-form-model-item
  63. :labelCol="labelCol"
  64. :wrapperCol="wrapperCol"
  65. label="是否有效"
  66. prop="status">
  67. <a-switch checkedChildren="有效" unCheckedChildren="无效" v-model="model.status"/>
  68. </a-form-model-item>
  69. </a-col>
  70. </a-row>
  71. </a-form-model>
  72. </j-form-container>
  73. </a-spin>
  74. </template>
  75. <script>
  76. import { httpAction, getAction } from '@/api/manage'
  77. import { validateDuplicateValue } from '@/utils/util'
  78. export default {
  79. name: 'BusSalesPersonForm',
  80. components: {
  81. },
  82. props: {
  83. //表单禁用
  84. disabled: {
  85. type: Boolean,
  86. default: false,
  87. required: false
  88. }
  89. },
  90. data () {
  91. return {
  92. model:{
  93. },
  94. labelCol: {
  95. xs: { span: 24 },
  96. sm: { span: 5 },
  97. },
  98. wrapperCol: {
  99. xs: { span: 24 },
  100. sm: { span: 16 },
  101. },
  102. confirmLoading: false,
  103. validatorRules: {
  104. workNo: [
  105. { required: true, message: '请输入编号!'},
  106. ],
  107. name: [
  108. { required: true, message: '请输入姓名!'},
  109. ],
  110. phone: [
  111. { required: true, message: '请输入手机号!'},
  112. ],
  113. status: [
  114. { required: true, message: '请选择服务员是否有效!'},
  115. ],
  116. },
  117. url: {
  118. add: "/business/busSalesPerson/add",
  119. edit: "/business/busSalesPerson/edit",
  120. queryById: "/business/busSalesPerson/queryById"
  121. },
  122. userList:[],
  123. postList:[]
  124. }
  125. },
  126. computed: {
  127. formDisabled(){
  128. return this.disabled
  129. },
  130. },
  131. created () {
  132. //备份model原始值
  133. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  134. this.getHotelPost()
  135. },
  136. methods: {
  137. add () {
  138. this.edit(this.modelDefault);
  139. this.edit({status:true });
  140. },
  141. edit (record) {
  142. if (record.status == 1){
  143. record.status = true;
  144. }else {
  145. record.status = false;
  146. }
  147. record.postId = record.postIds.split(',');
  148. this.model = Object.assign({}, record);
  149. this.visible = true;
  150. },
  151. submitForm () {
  152. const that = this;
  153. // 触发表单验证
  154. this.$refs.form.validate(valid => {
  155. if (valid) {
  156. that.confirmLoading = true;
  157. let httpurl = '';
  158. let method = '';
  159. if(!this.model.id){
  160. httpurl+=this.url.add;
  161. var info = JSON.parse(localStorage.getItem("storeInfo"));
  162. this.model.hotelId = info.id;
  163. method = 'post';
  164. }else{
  165. httpurl+=this.url.edit;
  166. method = 'put';
  167. }
  168. var _model = this.model;
  169. if (_model.status){
  170. _model.status = 1;
  171. }else {
  172. _model.status = 0;
  173. }
  174. _model.postIds = this.model.postId.join(",")
  175. console.log(_model)
  176. this.$delete( _model, 'postId')
  177. httpAction(httpurl,_model,method).then((res)=>{
  178. if(res.success){
  179. that.$message.success(res.message);
  180. that.$emit('ok');
  181. }else{
  182. that.$message.warning(res.message);
  183. }
  184. }).finally(() => {
  185. that.confirmLoading = false;
  186. })
  187. }
  188. })
  189. },
  190. getHotelPost(){
  191. var that = this;
  192. var param = {
  193. dictName:'职务'
  194. }
  195. // var values = JSON.parse(JSON.stringify(param))
  196. that.confirmLoading = true;
  197. getAction('/business/busDictItem/queryList',param).then((res)=>{
  198. console.log(res)
  199. if(res.success){
  200. if (res.code == 200 && res.result) {
  201. this.postList = res.result;
  202. }
  203. }
  204. }).finally(() => {
  205. that.confirmLoading = false;
  206. })
  207. }
  208. }
  209. }
  210. </script>