Guest User

Untitled

a guest
Dec 15th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.51 KB | None | 0 0
  1. <template>
  2. <div>
  3. <crumbs-u>
  4. <a>物资申请</a>
  5. <a>库存领用列表</a>
  6. </crumbs-u>
  7. <sa-panel>
  8. <form compact>
  9. <label>需求编号</label>
  10. <input type="text" v-model="searchObj.F_FormNo" placeholder="请输入OA表单号">
  11. <label>申请人</label>
  12. <sa-input searchable remote @search="keyword => getEmployeeFn(keyword,1)">
  13. <sa-select v-model="searchObj.FApplyerId" :data="applyerList" value-key="id">
  14. <template scope="item">
  15. {{item.code}} {{item.text}}
  16. </template>
  17. </sa-select>
  18. </sa-input>
  19. <label>使用人</label>
  20. <sa-input searchable remote @search="keyword => getEmployeeFn(keyword,2)">
  21. <sa-select v-model="searchObj.FUserId" :data="userList" value-key="id">
  22. <template scope="item">
  23. {{item.code}} {{item.text}}
  24. </template>
  25. </sa-select>
  26. </sa-input>
  27. <label>物料名称编码</label>
  28. <sa-input searchable remote @search="keyword => getMaterialFn(keyword)" @focus="keyword => getMaterialFn(keyword)">
  29. <sa-select :data="materialList" v-model="searchObj.MATID" value-key="id"></sa-select>
  30. </sa-input>
  31. <label>需求时间</label>
  32. <sa-input range>
  33. <sa-datepicker v-model="searchObj['FApplyTime>=']" slot="start" :end="searchObj['FApplyTime<=']"></sa-datepicker>
  34. <sa-datepicker v-model="searchObj['FApplyTime<=']" slot="end" :start="searchObj['FApplyTime>=']"></sa-datepicker>
  35. </sa-input>
  36. <label>费用归属公司</label>
  37. <input type="text" v-model="searchObj['FUserCompanyName%']" placeholder="请输入费用归属公司">
  38. <label>公司体系</label>
  39. <sa-input>
  40. <sa-select v-model="searchObj.CompanyType" :data="companyTypeList"></sa-select>
  41. </sa-input>
  42. <div class="grow tr">
  43. <button type="button" secondary outline @click="resetFn">重置</button>
  44. <button type="button" outline @click="searchFn(true)">查询</button>
  45. </div>
  46. </form>
  47. </sa-panel>
  48. <sa-panel class="pt-0">
  49. <div class="mv-10">
  50. <button @click="exportFn">导出表格</button>
  51. <button :disabled="!selectedList.length" @click="batchTake">批量库存领用</button>
  52. </div>
  53. <sf-table-shell :fix-right="1" :fix-left="1" class="mb-15">
  54. <template scope="props">
  55. <table default class="nowrap">
  56. <tr>
  57. <th><sa-checkbox v-if="selectableList.length" :checked="selectableList.length && selectableList.length === selectedList.length" @change="selectAllFn"></sa-checkbox></th>
  58. <th>领用结果</th>
  59. <th>需求单号</th>
  60. <th>EBS处理单号</th>
  61. <th>需求类别</th>
  62. <th>物料名称</th>
  63. <th>物料编码</th>
  64. <th>数量</th>
  65. <th>承担部门</th>
  66. <th>承担公司</th>
  67. <th>申请时间</th>
  68. <th>希望完成时间</th>
  69. <th>申请人</th>
  70. <th>使用人</th>
  71. <th>操作</th>
  72. </tr>
  73. <template v-if="tableList.length">
  74. <tr v-for="(item, index) in tableList" :key="index">
  75. <td>
  76. <sa-checkbox v-if="item.FIsAllot !== 1" v-model="selectedList" :value="item"></sa-checkbox></td>
  77. <td>
  78. <span v-if="item.IsAllot !== '失败'" class="w-80 ellipsis inline-block" v-tooltip:right="item.FEBSMsg">{{item.IsAllot}}</span>
  79. <span v-else class="w-80 ellipsis inline-block" v-tooltip:right="item.FEBSMsg" style="color:#ef6000">{{item.IsAllot}}</span>
  80. </td>
  81. <td>{{item.F_FormNo}}</td>
  82. <td>{{item.DocIds}}</td>
  83. <td>{{item.MATTypeName}}</td>
  84. <td>{{item.FItemName}}</td>
  85. <td>{{item.FItemCode}}</td>
  86. <td>{{item.FQuantity}}</td>
  87. <td>{{item.DepartmentName}}</td>
  88. <td>{{item.FUserCompanyName}}</td>
  89. <td>{{item.FApplyTime == "1900-01-01" ? "-" : item.FApplyTime}}</td>
  90. <td>{{item.FExpectCompleteTime}}</td>
  91. <td>{{item.FApplyerName}}</td>
  92. <td>{{item.UserNameCode}}</td>
  93. <td>
  94. <button v-if="item.MATNeedFixCode==1" @click="showCode(item)">查看编码</button>
  95. <button v-if="item.FIsAllot==2||item.FIsAllot==0" @click="take(item)">库存领用</button>
  96. <button v-if="item.FIsAllot==0&&item.AllowReturn" @click="cancel(item)">撤销</button>
  97. </td>
  98. </tr>
  99. </template>
  100. <!-- <tr v-if="!tableList.length">
  101. <td colspan="24">
  102. <p class="no-result">未查询到相关数据,请尝试更换筛选条件后查询!</p>
  103. </td>
  104. </tr> -->
  105. </table>
  106. </template>
  107. </sf-table-shell>
  108. <sa-pagination has-text :total="pageObj.pageTotal" :page="pageObj.page" @change="pageFn"></sa-pagination>
  109. </sa-panel>
  110. <sa-modal ref="codeModal" title="查看编码" :width="900">
  111. <table default="default" class="nowrap">
  112. <tr>
  113. <th>固定编码</th>
  114. <th>
  115. <template v-if="materialObj.Status==2">
  116. 来源库存
  117. </template>
  118. <template v-else-if="materialObj.Status==1">
  119. 来源部门
  120. </template>
  121. </th>
  122. <th>来源公司</th>
  123. </tr>
  124. <tr v-for="item in materialObj.dataList" >
  125. <td>{{item.FFixCode}}</td>
  126. <td>
  127. <template v-if="materialObj.Status==2">
  128. {{item.FSubStockName}}
  129. </template>
  130. <template v-else-if="materialObj.Status==1">
  131. {{item.FDepartmentName }}
  132. </template>
  133. </td>
  134. <td>{{item.FCompanyName }}</td>
  135. </tr>
  136. </table>
  137. </sa-modal>
  138. </div>
  139. </template>
  140. <script>
  141. import uniq from "lodash/uniq";
  142. export default {
  143. name: "MaterialTakeList",
  144. data() {
  145. return {
  146. applyerList: [],
  147. userList: [],
  148. b_applyerList: [],
  149. b_userList: [],
  150. materialList: [],
  151. typeList: [
  152. {
  153. Value: "",
  154. text: "所有"
  155. },
  156. {
  157. Value: "0",
  158. text: "否"
  159. },
  160. {
  161. Value: "1",
  162. text: "是"
  163. }
  164. ],
  165. defaultSearchObj: {},
  166. searchObj: {
  167. F_FormNo: "",
  168. FApplyerId: "",
  169. FUserId: "",
  170. MATID: "",
  171. "FApplyTime>=": "",
  172. "FApplyTime<=": "",
  173. "FUserCompanyName%": "",
  174. CompanyType: "ALL"
  175. },
  176. tableList: [],
  177. pageObj: {
  178. pageSize: 10,
  179. pageTotal: 0,
  180. page: 1
  181. },
  182. selectedList: [],
  183. sortingSelectedList: [],
  184. batchEditObj: {},
  185. editObj: {},
  186. companyTypeList: [],
  187. materialObj: {}
  188. };
  189. },
  190. computed: {
  191. selectableList() {
  192. return this.tableList.filter(item => {
  193. return !(item.MMPIsTurn == 1 || item.MMPIsValid == 0);
  194. });
  195. }
  196. },
  197. methods: {
  198. async initList() {
  199. var res = await this.$axios.get(
  200. this.$rootUrl + "/MaterialConfig/GetCompanyTypeJson"
  201. );
  202. this.companyTypeList = res.data;
  203. },
  204. getMaterialFn(keyword) {
  205. this.$axios
  206. .get(this.$rootUrl + "/Form065/GetMaterialDataJson", {
  207. params: {
  208. keyword: keyword,
  209. type: 0
  210. }
  211. })
  212. .then(res => {
  213. if (res.data.Success && res.data.Success === false) {
  214. this.$alert(res.data.Message);
  215. return;
  216. }
  217. this.materialList = res.data;
  218. });
  219. },
  220. searchFn(init = false) {
  221. this.selectedList = [];
  222. if (init) this.pageObj.page = this.searchObj.pageIndex = 1;
  223. this.$startWaiting();
  224. this.$axios
  225. .get(this.$rootUrl + "/MaterialTake/GetForm065SubListJson", {
  226. params: this.searchObj
  227. })
  228. .then(res => {
  229. this.$stopWaiting();
  230. if (res.data.Success && res.data.Success === false) {
  231. this.$alert(res.data.Message);
  232. return;
  233. }
  234. this.tableList = res.data.ReturnList;
  235. this.pageObj.pageTotal = res.data.TotalCount;
  236. });
  237. },
  238. resetFn() {
  239. $.extend(this.searchObj, this.defaultSearchObj);
  240. this.searchFn(true);
  241. },
  242. pageFn(page) {
  243. this.pageObj.page = this.searchObj.pageIndex = page;
  244. this.searchFn();
  245. },
  246. exportFn() {
  247. let url = `${this
  248. .$rootUrl}/MaterialTake/SubListExport?${this.$Qs.stringify(
  249. this.searchObj
  250. )}`;
  251. window.open(url, "_self");
  252. },
  253. selectAllFn() {
  254. if (this.selectableList.length === this.selectedList.length) {
  255. this.selectedList = [];
  256. } else {
  257. this.selectedList = [...this.selectableList];
  258. }
  259. },
  260. async getEmployeeFn(keyword, flag) {
  261. //1-申请人 2-使用人 3-实际申请人 4-收货人 5-批量-实际申请人 6-批量收货人
  262. if (!keyword) return;
  263. let list = await this.$axios
  264. .get(`${this.$rootUrl}/Form058/QueryEmployee`, {
  265. params: {
  266. keyword
  267. }
  268. })
  269. .then(res => {
  270. if (res.data.Success && res.data.Success === false) {
  271. this.$alert(res.data.Message);
  272. return [];
  273. }
  274. return res.data.map(item => {
  275. item.id = parseInt(item.id);
  276. return item;
  277. });
  278. });
  279. switch (flag) {
  280. case 1:
  281. this.applyerList = list;
  282. break;
  283. case 2:
  284. this.userList = list;
  285. break;
  286. case 3:
  287. this.editObj.employeesList = list;
  288. break;
  289. case 4:
  290. this.editObj.recipientList = list;
  291. break;
  292. case 5:
  293. this.b_applyerList = list;
  294. break;
  295. case 6:
  296. this.b_userList = list;
  297. break;
  298. }
  299. },
  300. // 撤销
  301. cancel(item) {
  302. this.$confirm("确认要撤销吗?").then(r => {
  303. if (r) {
  304. this.$startWaiting();
  305. this.$axios
  306. .post(
  307. this.$rootUrl + "/MaterialTake/ReturnTake",
  308. this.$Qs.stringify({
  309. subId: item.FormSubID,
  310. lineNo: item.FLineNo
  311. })
  312. )
  313. .then(res => {
  314. this.$stopWaiting();
  315. if (res.data.Success) {
  316. this.$toast("撤销成功!");
  317. if (res.data.Source && res.data.Source.length > 0) {
  318. let cacheKey = item.FormID + "-" + item.FItemCode;
  319. let cacheString = window.localStorage.getItem(cacheKey);
  320. if (cacheString && cacheString.length > 0) {
  321. let array = JSON.parse(cacheString);
  322. for (var i in res.data.Source) {
  323. array.shift(res.data.Source[i]);
  324. }
  325. if (array.length == 0) {
  326. window.localStorage.setItem(cacheKey, "[]"); //不清除,防止别处调用报错
  327. } else {
  328. window.localStorage.setItem(
  329. cacheKey,
  330. JSON.stringify(array)
  331. );
  332. }
  333. }
  334. }
  335. this.searchFn();
  336. } else {
  337. this.$alert(res.data.Message);
  338. }
  339. })
  340. .catch(e => {
  341. this.$toast("操作失败,服务器错误");
  342. });
  343. }
  344. });
  345. },
  346. // 库存领用
  347. async take(item) {
  348. this.$startWaiting();
  349. try {
  350. var res = await this.$axios.post(
  351. this.$rootUrl + "/MaterialTake/TakeMaterial",
  352. this.$Qs.stringify({ subIds: item.FormSubID })
  353. );
  354. if (res.data.Success) {
  355. this.$alert("已提交EBS,请查看领用结果");
  356. this.searchFn();
  357. } else {
  358. this.$alert(res.data.Message);
  359. }
  360. } catch (e) {
  361. this.$stopWaiting();
  362. }
  363. },
  364. async batchTake() {
  365. this.$startWaiting();
  366. var subIds = this.selectedList.map(item => item.FormSubID).join(",");
  367. try {
  368. var res = await this.$axios.post(
  369. this.$rootUrl + "/MaterialTake/TakeMaterial",
  370. this.$Qs.stringify({ subIds: subIds })
  371. );
  372. if (res.data.Success) {
  373. this.$alert("已提交EBS,请查看领用结果");
  374. this.searchFn();
  375. } else {
  376. this.$alert(res.data.Message);
  377. }
  378. } catch (e) {
  379. this.$stopWaiting();
  380. }
  381. },
  382. showCode(item) {
  383. this.$startWaiting();
  384. this.$axios
  385. .post(this.$rootUrl + "/Form065/GetMaterialInfoList", {
  386. subid: item.FormSubID
  387. })
  388. .then(res => {
  389. this.$stopWaiting();
  390. let mobj = {};
  391. mobj.Status = 2;
  392. mobj.dataList = res.data;
  393. this.materialObj = mobj;
  394. console.log(this.materialObj);
  395. this.$refs.codeModal.open();
  396. });
  397. }
  398. },
  399. created() {
  400. this.searchFn();
  401. this.initList();
  402. $.extend(this.defaultSearchObj, this.searchObj);
  403. }
  404. };
  405. </script>
Add Comment
Please, Sign In to add comment