pojpsnList.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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">
  82. <el-button slot="append" icon="el-icon-more" @click="refereStaff"></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="job">
  96. <el-select v-model="form.job" 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-select v-model="form.jobs" multiple placeholder="请选择职责">
  105. <el-option
  106. v-for="item in options"
  107. :key="item.value"
  108. :label="item.label"
  109. :value="item.value">
  110. </el-option>
  111. </el-select> -->
  112. </el-form-item>
  113. </el-form>
  114. <div slot="footer" class="dialog-footer">
  115. <el-button type="primary" @click="submitForm">确 定</el-button>
  116. <el-button @click="cancel">取 消</el-button>
  117. </div>
  118. </el-dialog>
  119. <!-- 员工参照 -->
  120. <StaffRef
  121. ref="contractSelect"
  122. @doSubmit="selectionsToInput"
  123. :single="true"
  124. />
  125. </div>
  126. </template>
  127. <script>
  128. import { listPojpsn, getPojpsn, delPojpsn, addPojpsn, updatePojpsn } from "@/api/business/spd/bo/pojpsn";
  129. import StaffRef from '@/views/business/spd/bo/refer/staff/index.vue';
  130. export default {
  131. name: "pojpsnList",
  132.   props:["source","bo"],
  133. dicts: ['mk_bo_pojpsn_post','mk_bo_pojpsn_job'],
  134. components: {StaffRef},
  135. data() {
  136. return {
  137. // 遮罩层
  138. loading: true,
  139. // 选中数组
  140. ids: [],
  141. // 非单个禁用
  142. single: true,
  143. // 非多个禁用
  144. multiple: true,
  145. // 显示搜索条件
  146. showSearch: true,
  147. // 总条数
  148. total: 0,
  149. // 项目成员表格数据
  150. pojpsnList: [],
  151. // 弹出层标题
  152. title: "",
  153. // 是否显示弹出层
  154. open: false,
  155. // 查询参数
  156. queryParams: {
  157. pageNum: 1,
  158. pageSize: 10,
  159. bo: null,
  160. boName: null,
  161. staffName: null,
  162. post: null,
  163. job: null,
  164. },
  165. // 表单参数
  166. form: {},
  167. // 表单校验
  168. rules: {
  169. staffName: [
  170. { required: true, message: "员工不能为空", trigger: "blur" }
  171. ],
  172. post: [
  173. { required: true, message: "岗位不能为空", trigger: "blur" }
  174. ],
  175. job: [
  176. { required: true, message: "职责不能为空", trigger: "blur" }
  177. ],
  178. },
  179. //
  180. jobs : [],
  181. options: [{
  182. value: '0',
  183. label: '上传商机审会议'
  184. }, {
  185. value: '1',
  186. label: '售前提案'
  187. }, {
  188. value: '2',
  189. label: '调研报告'
  190. }, {
  191. value: '3',
  192. label: '考察报告'
  193. }, {
  194. value: '4',
  195. label: '投标书'
  196. },],
  197. };
  198. },
  199. created() {
  200. if(this.source == 'Pojpsn'){
  201. this.queryParams = this.bo;
  202. }
  203. if(this.source == 'BoDetails'){
  204. this.queryParams.bo = this.bo.id;
  205. }
  206. this.getList();
  207. },
  208. watch: {
  209. //阶段
  210. "jobs": {
  211. handler(newName, oldName) {
  212. this.form.job = newName.toString();
  213. console.log(value1,value2);
  214. },
  215. immediate: true,
  216. },
  217. },
  218. methods: {
  219. /** 查询项目成员列表 */
  220. getList() {
  221. this.loading = true;
  222. listPojpsn(this.queryParams).then(response => {
  223. this.pojpsnList = response.rows;
  224. this.total = response.total;
  225. this.loading = false;
  226. });
  227. },
  228. // 取消按钮
  229. cancel() {
  230. this.open = false;
  231. this.reset();
  232. },
  233. // 表单重置
  234. reset() {
  235. this.form = {
  236. id: null,
  237. bo: null,
  238. boName: null,
  239. staff: null,
  240. staffName: null,
  241. post: null,
  242. job: null,
  243. tenantId: null,
  244. revision: null,
  245. createBy: null,
  246. createTime: null,
  247. updateBy: null,
  248. updateTime: null,
  249. delFlag: null
  250. };
  251. this.resetForm("form");
  252. },
  253. /** 搜索按钮操作 */
  254. handleQuery() {
  255. this.queryParams.pageNum = 1;
  256. this.getList();
  257. },
  258. /** 重置按钮操作 */
  259. resetQuery() {
  260. this.resetForm("queryForm");
  261. this.handleQuery();
  262. },
  263. // 多选框选中数据
  264. handleSelectionChange(selection) {
  265. this.ids = selection.map(item => item.id)
  266. this.single = selection.length!==1
  267. this.multiple = !selection.length
  268. },
  269. /** 新增按钮操作 */
  270. handleAdd() {
  271. this.reset();
  272. if(this.source == 'BoDetails'){
  273. this.form.bo = this.bo.id;
  274. this.form.boName = this.bo.boName;
  275. }
  276. this.open = true;
  277. this.title = "添加项目成员";
  278. },
  279. /** 修改按钮操作 */
  280. handleUpdate(row) {
  281. this.reset();
  282. const id = row.id || this.ids
  283. getPojpsn(id).then(response => {
  284. this.form = response.data;
  285. this.open = true;
  286. this.title = "修改项目成员";
  287. });
  288. },
  289. /** 提交按钮 */
  290. submitForm() {
  291. this.$refs["form"].validate(valid => {
  292. if (valid) {
  293. if (this.form.id != null) {
  294. updatePojpsn(this.form).then(response => {
  295. this.$modal.msgSuccess("修改成功");
  296. this.open = false;
  297. this.getList();
  298. });
  299. } else {
  300. addPojpsn(this.form).then(response => {
  301. this.$modal.msgSuccess("新增成功");
  302. this.open = false;
  303. this.getList();
  304. });
  305. }
  306. }
  307. });
  308. },
  309. /** 删除按钮操作 */
  310. handleDelete(row) {
  311. const ids = row.id || this.ids;
  312. this.$modal.confirm('是否确认删除项目成员编号为"' + ids + '"的数据项?').then(function() {
  313. return delPojpsn(ids);
  314. }).then(() => {
  315. this.getList();
  316. this.$modal.msgSuccess("删除成功");
  317. }).catch(() => {});
  318. },
  319. /** 导出按钮操作 */
  320. handleExport() {
  321. this.download('system/pojpsn/export', {
  322. ...this.queryParams
  323. }, `pojpsn_${new Date().getTime()}.xlsx`)
  324. },
  325. // 触发员工参照列表
  326. refereStaff() {
  327. console.log('测试点击')
  328. this.$refs.contractSelect.init()
  329. },
  330. //员工参照列表选择后
  331. selectionsToInput (selections) {
  332. this.form.staff = selections[0].userId;
  333. this.form.staffName = selections[0].nickName;
  334. }
  335. }
  336. };
  337. </script>