createPeople.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <div>
  3. <el-dialog
  4. v-dialog-drag
  5. class="dialog"
  6. title="新建人员配置"
  7. :visible.sync="dialogVisible"
  8. @before-close="close"
  9. width="600px"
  10. left
  11. >
  12. <el-divider></el-divider>
  13. <el-form
  14. label-position="left"
  15. label-width="80px"
  16. >
  17. <el-form-item label="人员类别:">
  18. <el-select
  19. v-model="personnelCategoryIndex"
  20. placeholder="请选择"
  21. disabled
  22. >
  23. <el-option
  24. v-for="item in personnelCategory"
  25. :key="item.value"
  26. :label="item.label"
  27. :value="item.value"
  28. >
  29. </el-option>
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item label="职责范围:">
  33. <el-input
  34. placeholder="请输入内容"
  35. v-model="form.responsibility_range"
  36. >
  37. </el-input>
  38. </el-form-item>
  39. <el-form-item label="人员名单:">
  40. <el-select
  41. v-model="form.staff_list"
  42. multiple
  43. placeholder="请选择"
  44. value-key="id"
  45. >
  46. <el-option
  47. v-for="item in peopleArr"
  48. :key="item.id"
  49. :label="item.name"
  50. :value="item"
  51. >
  52. </el-option>
  53. </el-select>
  54. </el-form-item>
  55. <el-form-item label="值班日期:">
  56. <el-date-picker
  57. v-model="form.duty_time.start_time"
  58. type="datetime"
  59. placeholder="选择日期时间"
  60. >
  61. </el-date-picker> 至
  62. <el-date-picker
  63. v-model="form.duty_time.stop_time"
  64. type="datetime"
  65. placeholder="选择日期时间"
  66. >
  67. </el-date-picker>
  68. </el-form-item>
  69. <el-form-item
  70. label="备注:"
  71. style="display:block"
  72. >
  73. <el-input
  74. type="textarea"
  75. :rows="2"
  76. placeholder="请输入内容"
  77. v-model="form.remark"
  78. >
  79. </el-input>
  80. </el-form-item>
  81. </el-form>
  82. <div
  83. slot="footer"
  84. class="dialog-footer"
  85. >
  86. <el-button
  87. @click="close"
  88. type="primary"
  89. >取消</el-button>
  90. <el-button
  91. type="primary"
  92. @click="sure"
  93. >确认</el-button>
  94. </div>
  95. </el-dialog>
  96. </div>
  97. </template>
  98. <script>
  99. import api from "@/api/infoConfig/api";
  100. export default {
  101. props: {
  102. itemInfo: {
  103. type: Object,
  104. },
  105. update: {
  106. type: Function,
  107. },
  108. },
  109. data() {
  110. return {
  111. value: "",
  112. dialogVisible: false,
  113. form: {
  114. personnel_type: "1",
  115. responsibility_range: "",
  116. staff_list: [],
  117. duty_time: {
  118. start_time: "",
  119. stop_time: "",
  120. },
  121. remark: "",
  122. },
  123. personnelCategoryIndex: "1",
  124. personnelCategory: [
  125. {
  126. value: "1",
  127. label: "驻地物业",
  128. },
  129. ],
  130. peopleArr: [],
  131. };
  132. },
  133. mounted() {
  134. this.getPersonList();
  135. },
  136. methods: {
  137. getPersonList() {
  138. api
  139. .getPersonList({ type_id: 1 })
  140. .then((result) => {
  141. // "access": null,
  142. // "account": null,
  143. // "address": null,
  144. // "car_number": null,
  145. // "card_number": null,
  146. // "company_id": null,
  147. // "company_name": null,
  148. // "create_time": null,
  149. // "dept_id": null,
  150. // "dept_name": null,
  151. // "duty": null,
  152. // "email": null,
  153. // "floor": null,
  154. // "function_type": null,
  155. // "hiredate": null,
  156. // "hr_number": null,
  157. // "id": 3,
  158. // "id_card": null,
  159. // "impower_time": null,
  160. // "in_out": null,
  161. // "is_del": 0,
  162. // "issue_status": null,
  163. // "name": "\u5f20\u707f",
  164. // "operate_status": null,
  165. // "phone": "010-68799999-6688",
  166. // "physics_card": null,
  167. // "role": null,
  168. // "room_number": null,
  169. // "site_number": "0399",
  170. // "status": 0,
  171. // "type": 1,
  172. // "update_time": null,
  173. // "work_address": null,
  174. // "zy_number": null
  175. this.peopleArr = result.data.data;
  176. })
  177. .catch((err) => {});
  178. },
  179. sure() {
  180. let that = this;
  181. let form = JSON.parse(JSON.stringify(this.form));
  182. form.duty_time.start_time = this.$dayjs(form.duty_time.start_time).format(
  183. "YYYY-MM-DD HH:mm:ss"
  184. );
  185. form.duty_time.stop_time = this.$dayjs(form.duty_time.stop_time).format(
  186. "YYYY-MM-DD HH:mm:ss"
  187. );
  188. form.duty_time = JSON.stringify(form.duty_time);
  189. form.staff_list = JSON.stringify(
  190. form.staff_list.map(function (item) {
  191. return {
  192. id: item.id,
  193. details: item,
  194. };
  195. })
  196. );
  197. form.id = this.itemInfo.data.id;
  198. // console.log(form);
  199. const loading = this.$loading({
  200. lock: true,
  201. text: "新建中,请稍后!",
  202. spinner: "el-icon-loading",
  203. background: "rgba(0, 0, 0, 0.7)",
  204. customClass: "systemConfigLoading",
  205. });
  206. // setTimeout(() => {
  207. // loading.close();
  208. // this.update();
  209. // this.$message.success("添加成功!");
  210. // this.dialogVisible = false;
  211. // }, 1000);
  212. // return;
  213. api
  214. .addPerson(form)
  215. .then((result) => {
  216. loading.close();
  217. if (result.data.code == 0) {
  218. this.update();
  219. this.$message.success("添加成功!");
  220. this.dialogVisible = false;
  221. } else {
  222. this.$message.error("添加失败!");
  223. }
  224. })
  225. .catch((err) => {
  226. this.$message.error("添加失败!");
  227. });
  228. // setTimeout(() => {
  229. // loading.close();
  230. // that.dialogVisible = true;
  231. // }, 2000);
  232. },
  233. close() {
  234. // this.form = {
  235. // personnelCategoryIndex: "",
  236. // responsibilities: "",
  237. // people: [],
  238. // beizhu: "",
  239. // start: "",
  240. // stop: "",
  241. // };
  242. this.dialogVisible = false;
  243. },
  244. },
  245. watch: {
  246. dialogVisible(newVal) {
  247. if (newVal) this.getPersonList();
  248. },
  249. },
  250. };
  251. </script>
  252. <style lang="less" scoped>
  253. .el-select {
  254. width: 280px;
  255. }
  256. .el-form {
  257. .el-form-item {
  258. margin-inline: 20px;
  259. }
  260. /deep/.el-form-item__label {
  261. padding: 0;
  262. }
  263. /deep/.el-form-item__content {
  264. // display: flex;
  265. text-align: left;
  266. }
  267. }
  268. /deep/.el-dialog__header {
  269. padding-bottom: 0;
  270. color: #333333;
  271. }
  272. /deep/.el-dialog__headerbtn {
  273. font-size: 25px;
  274. }
  275. /deep/.el-dialog__body {
  276. padding: 0;
  277. }
  278. /deep/.el-divider--horizontal {
  279. display: block;
  280. height: 1px;
  281. width: 100%;
  282. margin: 0;
  283. // margin-left: 2.5%;
  284. }
  285. // /deep/.el-dialog__footer {
  286. // // margin-top: 60px;
  287. // }
  288. .el-button {
  289. width: 100px;
  290. height: 30px;
  291. text-align: center;
  292. padding: 5px;
  293. }
  294. .el-image {
  295. width: 380px;
  296. height: 120px;
  297. cursor: pointer;
  298. }
  299. // .el-image + div {
  300. // }
  301. </style>