relationshipList.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10" class="mb8">
  4. <el-col :span="1.5">
  5. <el-button
  6. type="primary"
  7. plain
  8. icon="el-icon-plus"
  9. size="mini"
  10. @click="handleAdd"
  11. >新增</el-button>
  12. </el-col>
  13. <el-col :span="1.5">
  14. <el-button
  15. type="success"
  16. plain
  17. icon="el-icon-edit"
  18. size="mini"
  19. :disabled="single"
  20. @click="handleUpdate"
  21. >修改</el-button>
  22. </el-col>
  23. <el-col :span="1.5">
  24. <el-button
  25. type="danger"
  26. plain
  27. icon="el-icon-delete"
  28. size="mini"
  29. :disabled="multiple"
  30. @click="handleDelete"
  31. >删除</el-button>
  32. </el-col>
  33. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  34. </el-row>
  35. <el-table v-loading="loading" :data="relationshipList" @selection-change="handleSelectionChange">
  36. <el-table-column type="selection" width="55" align="center" />
  37. <el-table-column label="关系类型" align="center" prop="relationship" >
  38. <template slot-scope="scope">
  39. <dict-tag :options="dict.type.mk_bo_relationship" :value="scope.row.relationship"/>
  40. </template>
  41. </el-table-column>
  42. <el-table-column label="姓名" align="center" prop="name" />
  43. <el-table-column label="电话" align="center" prop="telephone" />
  44. <el-table-column label="出生日期" align="center" prop="enrollDate" width="180">
  45. <template slot-scope="scope">
  46. <span>{{ parseTime(scope.row.enrollDate, '{y}-{m}-{d}') }}</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="就读学校" align="center" prop="school" />
  50. <el-table-column label="工作单位" align="center" prop="company" />
  51. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  52. <template slot-scope="scope">
  53. <el-button
  54. size="mini"
  55. type="text"
  56. icon="el-icon-edit"
  57. @click="handleUpdate(scope.row)"
  58. >修改</el-button>
  59. <el-button
  60. size="mini"
  61. type="text"
  62. icon="el-icon-delete"
  63. @click="handleDelete(scope.row)"
  64. >删除</el-button>
  65. </template>
  66. </el-table-column>
  67. </el-table>
  68. <pagination
  69. v-show="total>0"
  70. :total="total"
  71. :page.sync="queryParams.pageNum"
  72. :limit.sync="queryParams.pageSize"
  73. @pagination="getList"
  74. />
  75. <!-- 添加或修改联系人社会关系对话框 -->
  76. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  77. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  78. <!-- <el-form-item label="联系人ID" prop="contactId">
  79. <el-input v-model="form.contactId" placeholder="请输入联系人ID" />
  80. </el-form-item> -->
  81. <el-form-item label="关系类型" prop="relationship">
  82. <el-select v-model="form.relationship" placeholder="请输入关系类型">
  83. <el-option
  84. v-for="dict in dict.type.mk_bo_relationship"
  85. :key="dict.value"
  86. :label="dict.label"
  87. :value="dict.value"
  88. ></el-option>
  89. </el-select>
  90. </el-form-item>
  91. <el-form-item label="姓名" prop="name">
  92. <el-input v-model="form.name" placeholder="请输入姓名" />
  93. </el-form-item>
  94. <el-form-item label="电话" prop="telephone">
  95. <el-input v-model="form.telephone" placeholder="请输入电话" />
  96. </el-form-item>
  97. <el-form-item label="出生日期" prop="enrollDate">
  98. <el-date-picker clearable
  99. v-model="form.enrollDate"
  100. type="date"
  101. value-format="yyyy-MM-dd"
  102. placeholder="请选择出生日期">
  103. </el-date-picker>
  104. </el-form-item>
  105. <el-form-item label="就读学校" prop="school">
  106. <el-input v-model="form.school" placeholder="请输入就读学校" />
  107. </el-form-item>
  108. <el-form-item label="工作单位" prop="company">
  109. <el-input v-model="form.company" placeholder="请输入工作单位" />
  110. </el-form-item>
  111. </el-form>
  112. <div slot="footer">
  113. <el-button type="primary" @click="submitForm" :disabled="submitButtonEditStatus">确 定</el-button>
  114. <el-button @click="cancel">取 消</el-button>
  115. </div>
  116. </el-dialog>
  117. </div>
  118. </template>
  119. <script>
  120. import { listRelationship, getRelationship, delRelationship, addRelationship, updateRelationship } from "@/api/business/spd/bo/relationship";
  121. export default {
  122. name: "RelationshipList",
  123. props:["source","supForm"],
  124. dicts: ['mk_bo_relationship'],
  125. data() {
  126. return {
  127. // 遮罩层
  128. loading: true,
  129. // 选中数组
  130. ids: [],
  131. // 非单个禁用
  132. single: true,
  133. // 非多个禁用
  134. multiple: true,
  135. // 显示搜索条件
  136. showSearch: true,
  137. // 总条数
  138. total: 0,
  139. // 联系人社会关系表格数据
  140. relationshipList: [],
  141. // 弹出层标题
  142. title: "",
  143. // 是否显示弹出层
  144. open: false,
  145. // 查询参数
  146. queryParams: {
  147. pageNum: 1,
  148. pageSize: 10,
  149. contactId: null,
  150. company: null,
  151. school: null,
  152. enrollDate: null,
  153. telephone: null,
  154. name: null,
  155. relationship: null,
  156. code: null,
  157. },
  158. // 表单参数
  159. form: {},
  160. // 表单校验
  161. rules: {
  162. relationship: [
  163. { required: true, message: "关系类型不能为空", trigger: "blur" }
  164. ],
  165. name: [
  166. { required: true, message: "姓名不能为空", trigger: "blur" }
  167. ],
  168. telephone: [
  169. { required: true, message: "电话不能为空", trigger: "blur" },
  170. {
  171. validator: function(rule, value, callback) {
  172. if (/^1[34578]\d{9}$/.test(value) == false) {
  173. callback(new Error("手机号格式错误"));
  174. } else {
  175. callback();
  176. }
  177. },
  178. trigger: "blur"
  179. }
  180. ],
  181. },
  182. //确定按钮是否可点
  183. submitButtonEditStatus:false,
  184. };
  185. },
  186. created() {
  187. if(this.source == 'ContactList'){
  188. this.queryParams.contactId = this.supForm.id;
  189. }
  190. this.getList();
  191. },
  192. methods: {
  193. /** 查询联系人社会关系列表 */
  194. getList() {
  195. this.loading = true;
  196. listRelationship(this.queryParams).then(response => {
  197. this.relationshipList = response.rows;
  198. this.total = response.total;
  199. this.loading = false;
  200. });
  201. },
  202. // 取消按钮
  203. cancel() {
  204. this.open = false;
  205. this.reset();
  206. },
  207. // 表单重置
  208. reset() {
  209. this.form = {
  210. contactId: null,
  211. delFlag: null,
  212. updateTime: null,
  213. updateBy: null,
  214. createTime: null,
  215. createBy: null,
  216. company: null,
  217. school: null,
  218. enrollDate: null,
  219. telephone: null,
  220. name: null,
  221. relationship: null,
  222. code: null,
  223. id: null
  224. };
  225. this.resetForm("form");
  226. },
  227. /** 搜索按钮操作 */
  228. handleQuery() {
  229. this.queryParams.pageNum = 1;
  230. this.getList();
  231. },
  232. /** 重置按钮操作 */
  233. resetQuery() {
  234. this.resetForm("queryForm");
  235. this.handleQuery();
  236. },
  237. // 多选框选中数据
  238. handleSelectionChange(selection) {
  239. this.ids = selection.map(item => item.id)
  240. this.single = selection.length!==1
  241. this.multiple = !selection.length
  242. },
  243. /** 新增按钮操作 */
  244. handleAdd() {
  245. this.operatingState = "Insert";
  246. this.reset();
  247. if(this.source == 'ContactList'){
  248. console.log('this.form.contactId',this.form.contactId);
  249. this.form.contactId = this.supForm.id;
  250. }
  251. this.open = true;
  252. this.title = "添加联系人社会关系";
  253. },
  254. /** 修改按钮操作 */
  255. handleUpdate(row) {
  256. this.reset();
  257. const id = row.id || this.ids
  258. getRelationship(id).then(response => {
  259. this.form = response.data;
  260. this.open = true;
  261. this.title = "修改联系人社会关系";
  262. });
  263. },
  264. /** 提交按钮 */
  265. submitForm() {
  266. this.submitButtonEditStatus = true;
  267. this.$refs["form"].validate(valid => {
  268. if (valid) {
  269. if (this.form.id != null) {
  270. updateRelationship(this.form).then(response => {
  271. this.$modal.msgSuccess("修改成功");
  272. this.open = false;
  273. this.getList();
  274. this.submitButtonEditStatus = false;
  275. });
  276. } else {
  277. addRelationship(this.form).then(response => {
  278. this.$modal.msgSuccess("新增成功");
  279. this.open = false;
  280. this.getList();
  281. this.submitButtonEditStatus = false;
  282. });
  283. }
  284. }else{
  285. this.submitButtonEditStatus = false;
  286. }
  287. });
  288. },
  289. /** 删除按钮操作 */
  290. handleDelete(row) {
  291. const ids = row.id || this.ids;
  292. this.$modal.confirm('是否确认删除联系人社会关系编号为"' + ids + '"的数据项?').then(function() {
  293. return delRelationship(ids);
  294. }).then(() => {
  295. this.getList();
  296. this.$modal.msgSuccess("删除成功");
  297. }).catch(() => {});
  298. },
  299. /** 导出按钮操作 */
  300. handleExport() {
  301. this.download('system/relationship/export', {
  302. ...this.queryParams
  303. }, `relationship_${new Date().getTime()}.xlsx`)
  304. }
  305. }
  306. };
  307. </script>