oaTool.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  1. layui.define(['tool'], function (exports) {
  2. const layer = layui.layer, tool = layui.tool, form = layui.form, table = layui.table, upload = layui.upload;
  3. // 查找指定的元素在数组中的位置
  4. Array.prototype.indexOf = function (val) {
  5. for (var i = 0; i < this.length; i++) {
  6. if (this[i] == val) {
  7. return i;
  8. }
  9. }
  10. return -1;
  11. };
  12. // 通过索引删除数组元素
  13. Array.prototype.remove = function (val) {
  14. var index = this.indexOf(val);
  15. if (index > -1) {
  16. this.splice(index, 1);
  17. }
  18. };
  19. //格式化文件大小
  20. function renderSize(value) {
  21. if (null == value || value == '') {
  22. return "0 Bytes";
  23. }
  24. var unitArr = new Array("Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB");
  25. var index = 0;
  26. var srcsize = parseFloat(value);
  27. index = Math.floor(Math.log(srcsize) / Math.log(1024));
  28. var size = srcsize / Math.pow(1024, index);
  29. size = size.toFixed(2);//保留的小数位数
  30. return size + unitArr[index];
  31. }
  32. const obj = {
  33. addFile: function (options) {
  34. console.log(options)
  35. let that = this;
  36. let settings = {
  37. type: 0,
  38. btn: 'uploadBtn',
  39. box: 'fileBox',
  40. url: "/admin/api/upload",
  41. accept: 'file', //普通文件
  42. exts: 'png|jpg|gif|jpeg|doc|docx|ppt|pptx|xls|xlsx|pdf|zip|rar|7z|txt|wps|avi|wmv|mpg|mov|rm|swf|flv|mp4|dwg|dxf|dwt|xmind', //只允许上传文件格式
  43. colmd: 4,
  44. isSave: false,
  45. uidDelete: false,
  46. ajaxSave: null,
  47. ajaxDelete: null
  48. };
  49. console.log(123123)
  50. let opts = $.extend({}, settings, options);
  51. let box = $('#' + opts.box);
  52. let boxInput = box.find('[data-type="file"]');
  53. console.log("wozaizheliyo")
  54. //删除
  55. box.on('click', '.btn-delete', function () {
  56. // let file_id = $(this).data('id');
  57. let file_id = $(this).parent().parent().data('id');
  58. let uid = $(this).data('uid');
  59. // if (uid != login_admin && opts.uidDelete == true) {
  60. // layer.msg('你不是该文件的上传人,无权限删除');
  61. // return false;
  62. // }
  63. let idsStr = boxInput.val(), idsArray = [];
  64. if (typeof idsStr !== 'undefined' && idsStr != '') {
  65. idsArray = idsStr.split(",");
  66. idsArray.remove(file_id);
  67. }
  68. layer.confirm('确定删除该附件吗?', {
  69. icon: 3,
  70. title: '提示'
  71. }, function (index) {
  72. if (typeof (opts.ajaxDelete) === "function") {
  73. //ajax删除
  74. if (opts.type == 1) {
  75. opts.ajaxDelete(file_id);
  76. } else {
  77. opts.ajaxDelete(idsArray.join(','));
  78. }
  79. } else {
  80. //虚拟删除
  81. boxInput.val(idsArray.join(','));
  82. $('#fileItem' + file_id).remove();
  83. }
  84. layer.close(index);
  85. });
  86. })
  87. //多附件上传
  88. upload.render({
  89. elem: '#' + opts.btn,
  90. url: opts.url,
  91. accept: opts.accept,
  92. exts: opts.exts,
  93. multiple: true,
  94. before: function (obj) {
  95. layer.msg('上传中...', {icon: 16, time: 0});
  96. },
  97. done: function (res) {
  98. if (res.code == 0) {
  99. //上传成功
  100. if (opts.type == 0) {
  101. let idsStr = boxInput.val(), idsArray = [];
  102. if (typeof idsStr !== 'undefined' && idsStr != '') {
  103. idsArray = idsStr.split(",");
  104. }
  105. idsArray.push(res.data.id);
  106. let filesize = renderSize(res.data.filesize);
  107. let type_icon = 'icon-sucaiziyuan';
  108. let view_btn = '<a class="blue" href="' + res.data.filepath + '" download="' + res.data.name + '" target="_blank" title="下载查看"><i class="iconfont icon-tuiguangshezhi"></i></a>';
  109. if (res.data.fileext == 'pdf') {
  110. type_icon = 'icon-lunwenguanli';
  111. view_btn = '<span class="file-view-pdf blue" data-href="' + res.data.filepath + '" title="在线查看"><i class="iconfont icon-yuejuan"></i></span>';
  112. }
  113. if (res.data.fileext == 'jpg' || res.data.fileext == 'jpeg' || res.data.fileext == 'png' || res.data.fileext == 'gif') {
  114. type_icon = 'icon-sucaiguanli';
  115. view_btn = '<span class="file-view-img blue" data-href="' + res.data.filepath + '" title="在线查看"><i class="iconfont icon-tupianguanli"></i></span>';
  116. }
  117. let temp = `<div class="layui-col-md${opts.colmd}" id="fileItem${res.data.id}">
  118. <div class="file-card">
  119. <i class="file-icon iconfont ${type_icon}"></i>
  120. <div class="file-info">
  121. <div class="file-title">${res.data.name}</div>
  122. <div class="file-ops">${filesize},一分钟前</div>
  123. </div>
  124. <div class="file-tool">${view_btn}<span class="btn-delete red" data-id="${res.data.id}" title="删除"><i class="iconfont icon-shanchu"></i></span></div>
  125. </div>
  126. </div>`;
  127. boxInput.val(idsArray.join(','));
  128. box.append(temp);
  129. if (typeof (opts.ajaxSave) === "function" && opts.isSave == true) {
  130. opts.ajaxSave(idsArray.join(','));
  131. } else {
  132. layer.msg(res.msg);
  133. }
  134. }
  135. if (opts.type == 1) {
  136. if (typeof (opts.ajaxSave) === "function" && opts.isSave == true) {
  137. opts.ajaxSave(res);
  138. }
  139. }
  140. } else {
  141. layer.msg(res.msg);
  142. }
  143. }
  144. });
  145. },
  146. //选择部门
  147. departmentPicker: function (type, callback) {
  148. let select_type = type == 1 ? 'radio' : 'checkbox', departmentTable;
  149. layer.open({
  150. type: 1,
  151. title: '选择部门',
  152. area: ['500px', '536px'],
  153. content: `<div style="width:468px; height:420px; padding:12px;">
  154. <div id="departmentBox"></div>
  155. </div>`,
  156. success: function () {
  157. departmentTable = table.render({
  158. elem: '#departmentBox'
  159. , url: "/api/index/get_department"
  160. , page: false //开启分页
  161. , cols: [[
  162. {type: select_type, title: '选择'}
  163. , {field: 'id', width: 80, title: '编号', align: 'center'}
  164. , {field: 'title', title: '部门名称'}
  165. ]]
  166. });
  167. },
  168. btn: ['确定'],
  169. btnAlign: 'c',
  170. yes: function () {
  171. var checkStatus = table.checkStatus(departmentTable.config.id);
  172. var data = checkStatus.data;
  173. if (data.length > 0) {
  174. callback(data);
  175. layer.closeAll();
  176. } else {
  177. layer.msg('请选择部门');
  178. return;
  179. }
  180. }
  181. })
  182. },
  183. //选择岗位
  184. positionPicker: function (type, callback) {
  185. let select_type = type == 1 ? 'radio' : 'checkbox', positionTable;
  186. layer.open({
  187. title: '选择岗位',
  188. type: 1,
  189. area: ['390px', '436px'],
  190. content: '<div style="padding:12px"><div id="positionBox"></div></div>',
  191. success: function () {
  192. positionTable = table.render({
  193. elem: '#positionBox'
  194. , url: "/api/index/get_position"
  195. , page: false //开启分页
  196. , cols: [[
  197. {type: select_type, title: '选择'}
  198. , {field: 'id', width: 80, title: '编号', align: 'center'}
  199. , {field: 'name', title: '岗位名称'}
  200. ]]
  201. });
  202. },
  203. btn: ['确定'],
  204. btnAlign: 'c',
  205. yes: function () {
  206. var checkStatus = table.checkStatus(positionTable.config.id);
  207. var data = checkStatus.data;
  208. if (data.length > 0) {
  209. callback(data);
  210. layer.closeAll();
  211. } else {
  212. layer.msg('请选择岗位');
  213. return;
  214. }
  215. }
  216. })
  217. },
  218. //选择服务类型
  219. servicePicker: function (type, callback) {
  220. let select_type = type == 1 ? 'radio' : 'checkbox', departmentTable;
  221. var serviceTable;
  222. layer.open({
  223. title: '选择服务类型',
  224. area: ['500px', '536px'],
  225. type: 1,
  226. content: '<div class="picker-table"><div id="serviceTable"></div></div>',
  227. success: function () {
  228. serviceTable = table.render({
  229. elem: '#serviceTable'
  230. , url: '/api/index/get_services'
  231. , page: false
  232. , cols: [[
  233. {type: select_type, title: '选择'}
  234. , {field: 'id', width: 100, title: '编号', align: 'center'}
  235. , {field: 'title', title: '服务名称'}
  236. ]]
  237. });
  238. },
  239. btn: ['确定'],
  240. btnAlign: 'c',
  241. yes: function () {
  242. var checkStatus = table.checkStatus(serviceTable.config.id);
  243. var data = checkStatus.data;
  244. if (data.length > 0) {
  245. callback(data);
  246. layer.closeAll();
  247. } else {
  248. layer.msg('请选择服务类型');
  249. return;
  250. }
  251. }
  252. })
  253. },
  254. //选择委托单位
  255. customerPicker: function (callback) {
  256. var customeTable;
  257. layer.open({
  258. title: '选择委托单位',
  259. area: ['600px', '580px'],
  260. type: 1,
  261. content: '<div class="picker-table">\
  262. <form class="layui-form pb-2">\
  263. <div class="layui-input-inline" style="width:480px;">\
  264. <input type="text" name="keywords" placeholder="委托单位" class="layui-input" autocomplete="off" />\
  265. </div>\
  266. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="search_customer">提交搜索</button>\
  267. </form>\
  268. <div id="customerTable"></div></div>',
  269. success: function () {
  270. customeTable = table.render({
  271. elem: '#customerTable'
  272. , url: '/admin/project.cost/get_customer'
  273. , page: true //开启分页
  274. , limit: 10
  275. , cols: [[
  276. {type: 'radio', title: '选择'},
  277. {field: 'id', width: 80, title: '编号', align: 'center'},
  278. {field: 'title', title: '评审单位名称', align: 'center'},
  279. {field: 'nickname', title: '评审单位负责人', align: 'center'},
  280. {field: 'mobile', title: '评审单位负责人电话', align: 'center'},
  281. {field: 'address', title: ' 评审单位地址', align: 'center'}
  282. ]]
  283. });
  284. //客户搜索提交
  285. form.on('submit(search_customer)', function (data) {
  286. customeTable.reload({where: {keywords: data.field.keywords}, page: {curr: 1}});
  287. return false;
  288. });
  289. },
  290. btn: ['确定'],
  291. btnAlign: 'c',
  292. yes: function () {
  293. var checkStatus = table.checkStatus(customeTable.config.id);
  294. var data = checkStatus.data;
  295. if (data.length > 0) {
  296. callback(data[0]);
  297. layer.closeAll();
  298. } else {
  299. layer.msg('请先选择评审单位');
  300. return false;
  301. }
  302. }
  303. })
  304. },
  305. //选择送审单位
  306. proprietorPicker : function (callback) {
  307. var proprietorTable;
  308. layer.open({
  309. title: '选择送审单位',
  310. area: ['600px', '580px'],
  311. type: 1,
  312. content: '<div class="picker-table">\
  313. <form class="layui-form pb-2">\
  314. <div class="layui-input-inline" style="width:480px;">\
  315. <input type="text" name="keywords" placeholder="送审单位" class="layui-input" autocomplete="off" />\
  316. </div>\
  317. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="search_customer">提交搜索</button>\
  318. </form>\
  319. <div id="customerTable"></div></div>',
  320. success: function () {
  321. proprietorTable = table.render({
  322. elem: '#customerTable'
  323. , url: '/admin/project.cost/get_proprietor_list'
  324. , page: true //开启分页
  325. , limit: 10
  326. , cols: [[
  327. {type: 'radio', title: '选择'},
  328. {field: 'id', width: 80, title: '编号', align: 'center'},
  329. {field: 'title', title: '送审单位名称', align: 'center'},
  330. {field: 'nickname', title: '送审单位负责人', align: 'center'},
  331. {field: 'mobile', title: '送审单位负责人电话', align: 'center'},
  332. {field: 'address', title: '送审单位地址', align: 'center'}
  333. ]]
  334. });
  335. //客户搜索提交
  336. form.on('submit(search_customer)', function (data) {
  337. proprietorTable.reload({where: {keywords: data.field.keywords}, page: {curr: 1}});
  338. return false;
  339. });
  340. },
  341. btn: ['确定'],
  342. btnAlign: 'c',
  343. yes: function () {
  344. var checkStatus = table.checkStatus(proprietorTable.config.id);
  345. var data = checkStatus.data;
  346. if (data.length > 0) {
  347. callback(data[0]);
  348. layer.closeAll();
  349. } else {
  350. layer.msg('请先选择送审单位');
  351. return false;
  352. }
  353. }
  354. })
  355. },
  356. //请款选择造价项目
  357. ProjectPicker: function (callback) {
  358. var projectTable;
  359. layer.open({
  360. title: '选择造价项目',
  361. area: ['600px', '580px'],
  362. type: 1,
  363. content: '<div class="picker-table">\
  364. <form class="layui-form pb-2">\
  365. <div class="layui-input-inline" style="width:480px;">\
  366. <input type="text" name="keywords" placeholder="造价项目" class="layui-input" autocomplete="off" />\
  367. </div>\
  368. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="search_customer">提交搜索</button>\
  369. </form>\
  370. <div id="customerTable"></div></div>',
  371. success: function () {
  372. projectTable = table.render({
  373. elem: '#customerTable'
  374. , url: '/admin/project.api/get_project'
  375. , page: true //开启分页
  376. , limit: 10
  377. , cols: [[
  378. {type: 'radio', title: '选择'},
  379. {field: 'id', width: 80, title: '编号', align: 'center'},
  380. {field: 'project_name', title: '项目名称', align: 'center'},
  381. {field: 'sent_review_cost', title: '送审服务费', align: 'center'},
  382. {field: 'entrust_unit_name', title: '委托单位', align: 'center'},
  383. ]]
  384. });
  385. //客户搜索提交
  386. form.on('submit(search_customer)', function (data) {
  387. projectTable.reload({where: {keywords: data.field.keywords}, page: {curr: 1}});
  388. return false;
  389. });
  390. },
  391. btn: ['确定'],
  392. btnAlign: 'c',
  393. yes: function () {
  394. var checkStatus = table.checkStatus(projectTable.config.id);
  395. var data = checkStatus.data;
  396. if (data.length > 0) {
  397. callback(data[0]);
  398. layer.closeAll();
  399. } else {
  400. layer.msg('请先选择项目');
  401. return false;
  402. }
  403. }
  404. })
  405. },
  406. //选择造价项目
  407. addProject: function (callback) {
  408. var projectTable;
  409. layer.open({
  410. title: '选择造价项目',
  411. area: ['600px', '580px'],
  412. type: 1,
  413. content: '<div class="picker-table">\
  414. <form class="layui-form pb-2">\
  415. <div class="layui-input-inline" style="width:480px;">\
  416. <input type="text" name="keywords" placeholder="造价项目" class="layui-input" autocomplete="off" />\
  417. </div>\
  418. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="search_customer">提交搜索</button>\
  419. </form>\
  420. <div id="customerTable"></div></div>',
  421. success: function () {
  422. projectTable = table.render({
  423. elem: '#customerTable'
  424. , url: '/admin/project.api/get_self_project'
  425. , page: true //开启分页
  426. , limit: 10
  427. , cols: [[
  428. {type: 'radio', title: '选择'},
  429. {field: 'id', width: 80, title: '编号', align: 'center'},
  430. {field: 'project_name', title: '项目名称', align: 'center'},
  431. {field: 'entrust_unit_name', title: '委托单位', align: 'center'},
  432. {field: 'review_unit_name', title: '评审单位', align: 'center'},
  433. ]]
  434. });
  435. //客户搜索提交
  436. form.on('submit(search_customer)', function (data) {
  437. projectTable.reload({where: {keywords: data.field.keywords}, page: {curr: 1}});
  438. return false;
  439. });
  440. },
  441. btn: ['确定'],
  442. btnAlign: 'c',
  443. yes: function () {
  444. var checkStatus = table.checkStatus(projectTable.config.id);
  445. var data = checkStatus.data;
  446. if (data.length > 0) {
  447. callback(data[0]);
  448. layer.closeAll();
  449. } else {
  450. layer.msg('请先选择项目');
  451. return false;
  452. }
  453. }
  454. })
  455. },
  456. //选择合同
  457. contractPicker: function (callback) {
  458. var contractTable;
  459. layer.open({
  460. title: '选择合同',
  461. area: ['720px', '580px'],
  462. type: 1,
  463. content: '<div class="picker-table">\
  464. <form class="layui-form pb-2">\
  465. <div class="layui-input-inline" style="width:600px;">\
  466. <input type="text" name="keywords" placeholder="合同名称" class="layui-input" autocomplete="off" />\
  467. </div>\
  468. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="search_contract">提交搜索</button>\
  469. </form>\
  470. <div id="contractTable"></div></div>',
  471. success: function () {
  472. contractTable = table.render({
  473. elem: '#contractTable'
  474. , url: '/contract/api/get_contract'
  475. , page: true //开启分页
  476. , limit: 10
  477. , cols: [[
  478. {type: 'radio', title: '选择'}
  479. , {field: 'code', width: 168, title: '合同编号', align: 'center'}
  480. , {field: 'name', title: '合同名称'}
  481. , {field: 'customer_name', title: '客户名称', width: 240}
  482. ]]
  483. });
  484. //合同搜索提交
  485. form.on('submit(search_contract)', function (data) {
  486. contractTable.reload({where: {keywords: data.field.keywords}, page: {curr: 1}});
  487. return false;
  488. });
  489. },
  490. btn: ['确定'],
  491. btnAlign: 'c',
  492. yes: function () {
  493. var checkStatus = table.checkStatus(contractTable.config.id);
  494. var data = checkStatus.data;
  495. if (data.length > 0) {
  496. callback(data[0]);
  497. layer.closeAll();
  498. } else {
  499. layer.msg('请先选择合同');
  500. return false;
  501. }
  502. }
  503. })
  504. },
  505. //选择项目
  506. // projectPicker: function (callback) {
  507. // var projectTable;
  508. // let projectLayer = layer.open({
  509. // title: '选择项目',
  510. // area: ['600px', '580px'],
  511. // type: 1,
  512. // content: '<div class="picker-table">\
  513. // <form class="layui-form pb-2">\
  514. // <div class="layui-input-inline" style="width:480px;">\
  515. // <input type="text" name="keywords" placeholder="项目名称" class="layui-input" autocomplete="off" />\
  516. // </div>\
  517. // <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="search_project">提交搜索</button>\
  518. // </form>\
  519. // <div id="projectTable"></div></div>',
  520. // success: function () {
  521. // projectTable = table.render({
  522. // elem: '#projectTable'
  523. // , url: '/project/api/get_project'
  524. // , page: true //开启分页
  525. // , limit: 10
  526. // , cols: [[
  527. // {type: 'radio', title: '选择'}
  528. // , {field: 'id', width: 100, title: '编号', align: 'center'}
  529. // , {field: 'title', title: '项目名称'}
  530. // ]]
  531. // });
  532. // //合同搜索提交
  533. // form.on('submit(search_project)', function (data) {
  534. // projectTable.reload({where: {keywords: data.field.keywords}, page: {curr: 1}});
  535. // return false;
  536. // });
  537. // },
  538. // btn: ['确定'],
  539. // btnAlign: 'c',
  540. // yes: function () {
  541. // var checkStatus = table.checkStatus(projectTable.config.id);
  542. // var data = checkStatus.data;
  543. // if (data.length > 0) {
  544. // callback(data[0]);
  545. // layer.close(projectLayer);
  546. // } else {
  547. // layer.msg('请先选择项目');
  548. // return false;
  549. // }
  550. // }
  551. // })
  552. // },
  553. //选择任务
  554. getEntrust: function (callback) {
  555. var entrustTable;
  556. let taskLayer = layer.open({
  557. title: '选择委托单位',
  558. area: ['600px', '580px'],
  559. type: 1,
  560. content: '<div class="picker-table">\
  561. <form class="layui-form pb-2">\
  562. <div class="layui-input-inline" style="width:480px;">\
  563. <input type="text" name="keywords" placeholder="委托单位" class="layui-input" autocomplete="off" />\
  564. </div>\
  565. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="entrustSearch">提交搜索</button>\
  566. </form>\
  567. <div id="entrustTable"></div></div>',
  568. success: function () {
  569. entrustTable = table.render({
  570. elem: '#entrustTable'
  571. , url: '/admin/project.api/get_entrust'
  572. , page: true //开启分页
  573. , limit: 10
  574. , cols: [[
  575. {type: 'radio', title: '选择'},
  576. {field: 'id', width: 80, title: '编号', align: 'center'},
  577. {field: 'title', title: '评审单位名称', align: 'center'},
  578. {field: 'nickname', title: '评审单位负责人', align: 'center'},
  579. {field: 'mobile', title: '评审单位负责人电话', align: 'center'},
  580. {field: 'address', title: ' 评审单位地址', align: 'center'}
  581. ]]
  582. });
  583. //合同搜索提交
  584. form.on('submit(entrustSearch)', function (data) {
  585. entrustTable.reload({where: {keywords: data.field.keywords}, page: {curr: 1}});
  586. return false;
  587. });
  588. },
  589. btn: ['确定'],
  590. btnAlign: 'c',
  591. yes: function () {
  592. var checkStatus = table.checkStatus(entrustTable.config.id);
  593. var data = checkStatus.data;
  594. if (data.length > 0) {
  595. callback(data[0]);
  596. layer.close(taskLayer);
  597. } else {
  598. layer.msg('请先选择任务主题');
  599. return false;
  600. }
  601. }
  602. })
  603. }
  604. };
  605. //选择部门
  606. $('body').on('click', '.picker-depament', function () {
  607. let that = $(this);
  608. let callback = function (data) {
  609. that.val(data[0].title);
  610. that.next().val(data[0].id);
  611. }
  612. obj.departmentPicker(1, callback);
  613. });
  614. $('body').on('click', '.picker-depaments', function () {
  615. let that = $(this), ids = [], names = [];
  616. let callback = function (data) {
  617. for (var i = 0; i < data.length; i++) {
  618. ids.push(data[i].id);
  619. names.push(data[i].title);
  620. }
  621. that.val(names.join(','));
  622. that.next().val(ids.join(','));
  623. }
  624. obj.departmentPicker(2, callback);
  625. });
  626. //选择岗位
  627. $('body').on('click', '.picker-position', function () {
  628. let that = $(this);
  629. let callback = function (data) {
  630. that.val(data[0].name);
  631. that.next().val(data[0].id);
  632. }
  633. obj.positionPicker(1, callback);
  634. });
  635. $('body').on('click', '.picker-positions', function () {
  636. let that = $(this), ids = [], names = [];
  637. let callback = function (data) {
  638. for (var i = 0; i < data.length; i++) {
  639. ids.push(data[i].id);
  640. names.push(data[i].name);
  641. }
  642. that.val(names.join(','));
  643. that.next().val(ids.join(','));
  644. }
  645. obj.positionPicker(2, callback);
  646. });
  647. //选择服务
  648. $('body').on('click', '.picker-service', function () {
  649. let that = $(this);
  650. let callback = function (data) {
  651. that.val(data[0].title);
  652. that.next().val(data[0].id);
  653. }
  654. obj.servicePicker(1, callback);
  655. });
  656. $('body').on('click', '.picker-services', function () {
  657. let that = $(this), ids = [], names = [];
  658. let callback = function (data) {
  659. for (var i = 0; i < data.length; i++) {
  660. ids.push(data[i].id);
  661. names.push(data[i].title);
  662. }
  663. that.val(names.join(','));
  664. that.next().val(ids.join(','));
  665. }
  666. obj.servicePicker(2, callback);
  667. });
  668. //选择客户
  669. $('body').on('click', '.picker-customer', function () {
  670. let that = $(this);
  671. let callback = function (data) {
  672. that.val(data.name);
  673. that.next().val(data.id);
  674. }
  675. obj.customerPicker(callback);
  676. });
  677. //选择合同
  678. $('body').on('click', '.picker-contract', function () {
  679. let that = $(this);
  680. let callback = function (data) {
  681. that.val(data.name);
  682. that.next().val(data.id);
  683. }
  684. obj.contractPicker(callback);
  685. });
  686. //选择项目
  687. $('body').on('click', '.picker-project', function () {
  688. let that = $(this);
  689. let callback = function (data) {
  690. that.val(data.title);
  691. that.next().val(data.id);
  692. }
  693. obj.projectPicker(callback);
  694. });
  695. exports('oaTool', obj);
  696. });