pojpsnList.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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="pojpsnList" @selection-change="handleSelectionChange">
  36. <el-table-column type="selection" width="55" align="center" />
  37. <!-- <el-table-column label="主键" align="center" prop="id" /> -->
  38. <el-table-column label="商机名称" align="center" prop="boName" v-if="source == 'Pojpsn'"/>
  39. <el-table-column label="员工名称" align="center" prop="staffName" />
  40. <el-table-column label="项目岗位" align="center" prop="post" >
  41. <template slot-scope="scope">
  42. <dict-tag :options="dict.type.mk_bo_pojpsn_post" :value="scope.row.post"/>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="职责" align="center" prop="job" >
  46. <template slot-scope="scope">
  47. <dict-tag :options="dict.type.mk_bo_pojpsn_job" :value="scope.row.job"/>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="操作" fixed="right" align="center" class-name="small-padding fixed-width">
  51. <template slot-scope="scope">
  52. <el-button
  53. size="mini"
  54. type="text"
  55. icon="el-icon-edit"
  56. @click="handleUpdate(scope.row)"
  57. >修改</el-button>
  58. <el-button
  59. size="mini"
  60. type="text"
  61. icon="el-icon-delete"
  62. @click="handleDelete(scope.row)"
  63. >删除</el-button>
  64. </template>
  65. </el-table-column>
  66. </el-table>
  67. <pagination
  68. v-show="total>0"
  69. :total="total"
  70. :page.sync="queryParams.pageNum"
  71. :limit.sync="queryParams.pageSize"
  72. @pagination="getList"
  73. />
  74. <!-- 添加或修改项目成员对话框 -->
  75. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  76. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  77. <!-- <el-form-item label="商机名称" prop="boName">
  78. <el-input v-model="form.boName" placeholder="商机名称" />
  79. </el-form-item> -->
  80. <el-form-item label="员工" prop="staffName">
  81. <el-input v-model="form.staffName" :disabled="this.operatingState != 'Insert'">
  82. <el-button slot="append" icon="el-icon-more" @click="refereStaff" :disabled="this.operatingState != 'Insert'"></el-button>
  83. </el-input>
  84. </el-form-item>
  85. <el-form-item label="项目岗位" prop="post">
  86. <el-select v-model="form.post" placeholder="请选择项目岗位">
  87. <el-option
  88. v-for="dict in dict.type.mk_bo_pojpsn_post"
  89. :key="dict.value"
  90. :label="dict.label"
  91. :value="dict.value"
  92. ></el-option>
  93. </el-select>
  94. </el-form-item>
  95. <el-form-item label="职责" prop="jobs">
  96. <el-select v-model="form.jobs" multiple placeholder="请选择职责">
  97. <el-option
  98. v-for="dict in dict.type.mk_bo_pojpsn_job"
  99. :key="dict.value"
  100. :label="dict.label"
  101. :value="dict.value">
  102. </el-option>
  103. </el-select>
  104. </el-form-item>
  105. </el-form>
  106. <div slot="footer" class="dialog-footer">
  107. <el-button type="primary" @click="submitForm">确 定</el-button>
  108. <el-button @click="cancel">取 消</el-button>
  109. </div>
  110. </el-dialog>
  111. <!-- 员工参照 -->
  112. <StaffRef
  113. ref="contractSelect"
  114. @doSubmit="selectionsToInput"
  115. :single="true"
  116. />
  117. </div>
  118. </template>
  119. <script>
  120. import { listPojpsn, getPojpsn, delPojpsn, addPojpsn, updatePojpsn } from "@/api/business/spd/bo/pojpsn";
  121. import StaffRef from '@/views/business/spd/bo/refer/staff/index.vue';
  122. export default {
  123. name: "pojpsnList",
  124.   props:["source","bo"],
  125. dicts: ['mk_bo_pojpsn_post','mk_bo_pojpsn_job'],
  126. components: {StaffRef},
  127. data() {
  128. return {
  129. // 遮罩层
  130. loading: true,
  131. // 选中数组
  132. ids: [],
  133. // 非单个禁用
  134. single: true,
  135. // 非多个禁用
  136. multiple: true,
  137. // 显示搜索条件
  138. showSearch: true,
  139. // 总条数
  140. total: 0,
  141. // 项目成员表格数据
  142. pojpsnList: [],
  143. // 弹出层标题
  144. title: "",
  145. // 是否显示弹出层
  146. open: false,
  147. // 查询参数
  148. queryParams: {
  149. pageNum: 1,
  150. pageSize: 10,
  151. bo: null,
  152. boName: null,
  153. staffName: null,
  154. post: null,
  155. job: null,
  156. },
  157. // 表单参数
  158. form: {},
  159. // 表单校验
  160. rules: {
  161. staffName: [
  162. { required: true, message: "员工不能为空", trigger: "blur" }
  163. ],
  164. post: [
  165. { required: true, message: "岗位不能为空", trigger: "blur" }
  166. ],
  167. jobs: [
  168. { required: true, message: "职责不能为空", trigger: "blur" }
  169. ],
  170. },
  171. //当前操作状态
  172. operatingState: '',
  173. };
  174. },
  175. created() {
  176. if(this.source == 'Pojpsn'){
  177. this.queryParams = this.bo;
  178. }
  179. if(this.source == 'BoDetails'){
  180. this.queryParams.bo = this.bo.id;
  181. }
  182. this.getList();
  183. },
  184. methods: {
  185. /** 查询项目成员列表 */
  186. getList() {
  187. this.loading = true;
  188. listPojpsn(this.queryParams).then(response => {
  189. this.pojpsnList = response.rows;
  190. this.total = response.total;
  191. this.loading = false;
  192. });
  193. },
  194. // 取消按钮
  195. cancel() {
  196. this.open = false;
  197. this.reset();
  198. this.jobs = [];
  199. },
  200. // 表单重置
  201. reset() {
  202. this.form = {
  203. id: null,
  204. bo: null,
  205. boName: null,
  206. staff: null,
  207. staffName: null,
  208. post: null,
  209. job: null,
  210. tenantId: null,
  211. revision: null,
  212. createBy: null,
  213. createTime: null,
  214. updateBy: null,
  215. updateTime: null,
  216. delFlag: null
  217. };
  218. this.resetForm("form");
  219. },
  220. /** 搜索按钮操作 */
  221. handleQuery() {
  222. this.queryParams.pageNum = 1;
  223. this.getList();
  224. },
  225. /** 重置按钮操作 */
  226. resetQuery() {
  227. this.resetForm("queryForm");
  228. this.handleQuery();
  229. },
  230. // 多选框选中数据
  231. handleSelectionChange(selection) {
  232. this.ids = selection.map(item => item.id)
  233. this.single = selection.length!==1
  234. this.multiple = !selection.length
  235. },
  236. /** 新增按钮操作 */
  237. handleAdd() {
  238. this.operatingState = "Insert";
  239. this.reset();
  240. if(this.source == 'BoDetails'){
  241. this.form.bo = this.bo.id;
  242. this.form.boName = this.bo.boName;
  243. }
  244. this.open = true;
  245. this.title = "添加项目成员";
  246. },
  247. /** 修改按钮操作 */
  248. handleUpdate(row) {
  249. this.operatingState = "Update";
  250. this.reset();
  251. const id = row.id || this.ids
  252. getPojpsn(id).then(response => {
  253. this.form = response.data;
  254. this.open = true;
  255. this.title = "修改项目成员";
  256. });
  257. },
  258. /** 提交按钮 */
  259. submitForm() {
  260. this.$refs["form"].validate(valid => {
  261. if (valid) {
  262. if (this.form.id != null) {
  263. updatePojpsn(this.form).then(response => {
  264. this.$modal.msgSuccess("修改成功");
  265. this.open = false;
  266. this.getList();
  267. });
  268. } else {
  269. addPojpsn(this.form).then(response => {
  270. this.$modal.msgSuccess("新增成功");
  271. this.open = false;
  272. this.getList();
  273. });
  274. }
  275. }
  276. });
  277. },
  278. /** 删除按钮操作 */
  279. handleDelete(row) {
  280. const ids = row.id || this.ids;
  281. this.$modal.confirm('是否确认删除项目成员编号为"' + ids + '"的数据项?').then(function() {
  282. return delPojpsn(ids);
  283. }).then(() => {
  284. this.getList();
  285. this.$modal.msgSuccess("删除成功");
  286. }).catch(() => {});
  287. },
  288. /** 导出按钮操作 */
  289. handleExport() {
  290. this.download('system/pojpsn/export', {
  291. ...this.queryParams
  292. }, `pojpsn_${new Date().getTime()}.xlsx`)
  293. },
  294. // 触发员工参照列表
  295. refereStaff() {
  296. console.log('测试点击')
  297. this.$refs.contractSelect.init()
  298. },
  299. //员工参照列表选择后
  300. selectionsToInput (selections) {
  301. this.form.staff = selections[0].userId;
  302. this.form.staffName = selections[0].nickName;
  303. }
  304. }
  305. };
  306. </script>