You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

361 lines
12 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
  1. <template>
  2. <div style="display: flex">
  3. <el-table
  4. :data="personnelUnit.personnelgrouping"
  5. style="width: 100%"
  6. row-key="id"
  7. highlight-current-row
  8. @row-click="clickoncolumn"
  9. class="el-table__body-wrapper tbody"
  10. >
  11. <el-table-column type="index" label="序号" width=""> </el-table-column>
  12. <el-table-column prop="displayName" label="名称" width="">
  13. </el-table-column>
  14. <el-table-column prop="creatorName" label="创建者"> </el-table-column>
  15. <el-table-column prop="" label="创建时间">
  16. <template slot-scope="scope">
  17. {{ scope.row.creationTime | dateFormat }}
  18. </template>
  19. </el-table-column>
  20. <el-table-column prop="forSexId" label="性别"> </el-table-column>
  21. <el-table-column prop="maritalStatusId" label="婚姻状况">
  22. </el-table-column>
  23. <el-table-column prop="price" label="价格"> </el-table-column>
  24. <el-table-column label="操作">
  25. <template>
  26. <el-tag
  27. class="move"
  28. style="cursor: move; margin-left: 15px"
  29. draggable="true"
  30. >
  31. <i class="el-icon-d-caret" style="width: 1rem; height: 1rem"></i>
  32. </el-tag>
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. <div style="margin-top: 3%; margin-left: 10px">
  37. <div style="margin-left: 10px; margin-top: 5%">
  38. <div style="margin-top: 10px">
  39. <el-button type="primary" @click="groupaddtion">新增</el-button>
  40. </div>
  41. <div style="margin-top: 10px">
  42. <el-button type="success" @click="editgroup">编辑</el-button>
  43. </div>
  44. <div style="margin-top: 10px">
  45. <el-button type="danger" @click="deletegroup">删除</el-button>
  46. </div>
  47. <div style="margin-top: 10px">
  48. <el-button type="primary" @click="topping">置顶</el-button>
  49. </div>
  50. <div style="margin-top: 10px">
  51. <el-button type="primary" @click="bottoming">置低</el-button>
  52. </div>
  53. <div style="margin-top: 10px">
  54. <el-button type="primary" @click="sortok" :disabled="isshow"
  55. >确定</el-button
  56. >
  57. </div>
  58. </div>
  59. </div>
  60. <!-- 新增或者编辑弹框 -->
  61. <el-dialog
  62. :title="title == '1' ? '新增' : '编辑'"
  63. :visible.sync="dialogVisible"
  64. width="50%"
  65. >
  66. <el-form :model="form" label-width="80px">
  67. <el-row>
  68. <el-col :span="8">
  69. <el-form-item label="分组名称">
  70. <el-input v-model="form.displayName"></el-input>
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="8">
  74. <el-form-item label="价格">
  75. <el-input v-model="form.price"></el-input>
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="8">
  79. <el-form-item label="适用性别">
  80. <el-select v-model="form.forSexId" placeholder="请选择">
  81. <el-option
  82. v-for="item in forSexId"
  83. :key="item.id"
  84. :label="item.displayName"
  85. :value="item.id"
  86. >
  87. </el-option>
  88. </el-select>
  89. </el-form-item>
  90. </el-col>
  91. <el-col :span="8">
  92. <el-form-item label="婚姻状况">
  93. <el-select v-model="form.maritalStatusId" placeholder="请选择">
  94. <el-option
  95. v-for="item in maritalStatusId"
  96. :key="item.id"
  97. :label="item.displayName"
  98. :value="item.id"
  99. >
  100. </el-option>
  101. </el-select>
  102. </el-form-item>
  103. </el-col>
  104. <el-col :span="8">
  105. <el-form-item label="年龄下限">
  106. <el-input v-model="form.ageLowerLimit"></el-input>
  107. </el-form-item>
  108. </el-col>
  109. <el-col :span="8">
  110. <el-form-item label="年龄上限">
  111. <el-input v-model="form.ageUpperLimit"></el-input>
  112. </el-form-item>
  113. </el-col>
  114. <el-col :span="8">
  115. <el-form-item label="适用职务">
  116. <el-input v-model="form.jobPost"></el-input>
  117. </el-form-item>
  118. </el-col>
  119. <el-col :span="8">
  120. <el-form-item label="适用职称">
  121. <el-input v-model="form.jobTitle"></el-input>
  122. </el-form-item>
  123. </el-col>
  124. <el-col :span="8">
  125. <el-form-item label="备注">
  126. <el-input v-model="form.remark"></el-input>
  127. </el-form-item>
  128. </el-col>
  129. </el-row>
  130. </el-form>
  131. <span slot="footer" class="dialog-footer">
  132. <el-button @click="dialogVisible = false"> </el-button>
  133. <el-button type="primary" @click="Onsubmint"> </el-button>
  134. </span>
  135. </el-dialog>
  136. <!-- -->
  137. </div>
  138. </template>
  139. <script>
  140. import nat from "@/views/customerOrg/customerOrgGroup.vue";
  141. import Sortable from "sortablejs";
  142. import { getapi, postapi, putapi, deletapi } from "@/api/api";
  143. import { mapState } from "vuex";
  144. export default {
  145. data() {
  146. return {
  147. isshow: true,
  148. title: 1,
  149. form: {
  150. displayName: "",
  151. price: "",
  152. forSexId: "",
  153. maritalStatusId: "",
  154. ageLowerLimit: "",
  155. ageUpperLimit: "",
  156. jobPost: "",
  157. jobTitle: "",
  158. remark: "",
  159. },
  160. forSexId: [], //性别id
  161. maritalStatusId: [], //婚姻状况
  162. dialogVisible: false,
  163. tableData: [],
  164. initTableData: [],
  165. // tableData: [
  166. // ],
  167. };
  168. },
  169. computed: {
  170. ...mapState(["personnelUnit"]),
  171. },
  172. created() {
  173. this.rowDrop();
  174. },
  175. mounted() {
  176. //console.log('00000',this.personnelUnit.id);
  177. },
  178. methods: {
  179. //确定排序
  180. sortok() {
  181. const result = [];
  182. this.tableData.forEach((item, index) => {
  183. // index 从0开始的, 你的displayOrder从大到小排
  184. console.log(item.id);
  185. // const currentDisplayOrder = this.tableData.length -1
  186. const currentDisplayOrder = this.initTableData[index].displayOrder;
  187. if (item.displayOrder != currentDisplayOrder) {
  188. // 如果它的displayOrder和它当前所在的位置不同代表挪动过位置
  189. result.push({ id: item.id, displayOrder: currentDisplayOrder });
  190. }
  191. });
  192. putapi("/api/app/customerorggroup/updatesortmany", {
  193. itemList: result,
  194. }).then((res) => {
  195. this.$message.success("操作成功");
  196. this.isshow = true;
  197. this.getlist();
  198. });
  199. },
  200. //初始化Sortable组件
  201. rowDrop() {
  202. this.$nextTick(() => {
  203. const tbody = document.querySelector(".el-table__body-wrapper tbody");
  204. const _this = this;
  205. Sortable.create(tbody, {
  206. handle: ".move",
  207. animation: 300,
  208. onEnd({ newIndex, oldIndex }) {
  209. _this.isshow = false;
  210. const currRow = _this.tableData.splice(oldIndex, 1)[0];
  211. _this.tableData.splice(newIndex, 0, currRow);
  212. _this.tableData.map((item, index) => {
  213. if (index == newIndex && index == oldIndex) {
  214. } else if (index == oldIndex) {
  215. } else if (index == newIndex) {
  216. }
  217. });
  218. console.log(_this.tableData.map((item) => item.displayOrder));
  219. },
  220. });
  221. });
  222. },
  223. getlist() {
  224. getapi(
  225. `/api/app/customer-org-group/in-customer-org-id/${this.personnelUnit.id}`
  226. ).then((res) => {
  227. this.tableData = res.data;
  228. this.personnelUnit.personnelgrouping = res.data;
  229. this.initTableData = [...res.data];
  230. // console.log( this.personnelUnit.personnelgrouping);
  231. });
  232. },
  233. //置低
  234. bottoming() {
  235. if (this.form.id == undefined) {
  236. this.$message.warning("请选择操作的数据");
  237. } else {
  238. putapi(
  239. `/api/app/customerorggroup/updatemanysort?id=${this.form.id}&SortType=2`
  240. ).then((res) => {
  241. this.$message.success("操作成功");
  242. this.getlist();
  243. });
  244. }
  245. },
  246. //置顶
  247. topping() {
  248. if (this.form.id == undefined) {
  249. this.$message.warning("请选择操作的数据");
  250. } else {
  251. putapi(
  252. `/api/app/customerorggroup/updatemanysort?id=${this.form.id}&SortType=1`
  253. ).then((res) => {
  254. this.$message.success("操作成功");
  255. this.getlist();
  256. });
  257. }
  258. },
  259. //删除
  260. deletegroup() {
  261. if (this.form.id == undefined) {
  262. this.$message.warning("请选择需要操作的数据");
  263. } else {
  264. deletapi(`/api/app/customer-org-group/${this.form.id}`).then((res) => {
  265. this.$message.success("删除成功");
  266. });
  267. }
  268. },
  269. //点击当前列
  270. clickoncolumn(row) {
  271. console.log(row.id);
  272. this.personnelUnit.customerOrgGroupId = row.id;
  273. getapi(`/api/app/customer-org-group/${row.id}`).then((res) => {
  274. this.form = res.data;
  275. this.personnelUnit.form = res.data;
  276. });
  277. // //
  278. console.log(this.personnelUnit.form.id);
  279. // getapi(
  280. // `/api/app/customer-org-group-detail/customer-org-group-detail-in-asbitem/${this.personnelUnit.form.id}`
  281. // ).then((res) => {
  282. // console.log(res.data, "当前列");
  283. // this.personnelUnit.nogroupselected = res.data;
  284. // console.log(this.personnelUnit.nogroupselected, "我是分组");
  285. // });
  286. },
  287. //编辑弹框
  288. editgroup() {
  289. this.title = 2;
  290. this.obtainsuperior();
  291. this.dialogVisible = true;
  292. },
  293. //获取性别和婚姻状况
  294. obtainsuperior() {
  295. //获取性别
  296. getapi("/api/app/sex").then((res) => {
  297. this.forSexId = res.data;
  298. });
  299. //获取婚姻状况
  300. getapi("/api/app/marital-statuses").then((res) => {
  301. this.maritalStatusId = res.data.items;
  302. console.log(res);
  303. });
  304. },
  305. Onsubmint() {
  306. if (this.title == 1) {
  307. let obj = {
  308. displayName: this.form.displayName,
  309. price: Number(this.form.price),
  310. forSexId: this.form.forSexId,
  311. maritalStatusId: this.form.maritalStatusId,
  312. ageLowerLimit: Number(this.form.ageLowerLimit),
  313. ageUpperLimit: Number(this.form.ageUpperLimit),
  314. jobPost: this.form.jobPost,
  315. jobTitle: this.form.jobTitle,
  316. remark: this.form.remark,
  317. };
  318. postapi(
  319. `/api/app/customer-org-group/in-customer-org-id/${this.personnelUnit.id}`,
  320. obj
  321. ).then((res) => {
  322. this.$message.success("新增成功");
  323. this.dialogVisible = false;
  324. });
  325. } else if (this.title == 2) {
  326. let obj = {
  327. displayName: this.form.displayName,
  328. price: Number(this.form.price),
  329. forSexId: this.form.forSexId,
  330. maritalStatusId: this.form.maritalStatusId,
  331. ageLowerLimit: Number(this.form.ageLowerLimit),
  332. ageUpperLimit: Number(this.form.ageUpperLimit),
  333. jobPost: this.form.jobPost,
  334. jobTitle: this.form.jobTitle,
  335. remark: this.form.remark,
  336. };
  337. putapi(`/api/app/customer-org-group/${this.form.id}`, obj).then(
  338. (res) => {
  339. this.$message.success("修改成功");
  340. this.dialogVisible = false;
  341. }
  342. );
  343. }
  344. },
  345. //新增弹框
  346. groupaddtion() {
  347. if (this.personnelUnit.id == "") {
  348. this.$message.warning("请选择单位");
  349. } else {
  350. this.dialogVisible = true;
  351. this.title = 1;
  352. this.form={}
  353. this.obtainsuperior();
  354. }
  355. },
  356. },
  357. };
  358. </script>