mixin.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. import { apiFlowDetail, apiSealAdd, apiSearchCustome, apiSearchContract,apiSearchAllCustome,getBelongCompany } from "@/api/approve/seal.js";
  2. import { uploadFiles } from "@/utils/uploadFile.js";
  3. import { preViewFile } from "../utils/util.js";
  4. export const sealMixin = {
  5. computed: {
  6. typeLength() {
  7. if (this.type.length > 0) {
  8. return true;
  9. } else {
  10. return false;
  11. }
  12. },
  13. },
  14. watch: {
  15. showCustome() {
  16. this.searchCustomeVal = "";
  17. this.searchCustomeStatus = true;
  18. this.searchCustomeList = [];
  19. this.searchContractList = [];
  20. },
  21. showType() {
  22. if (!this.showType) {
  23. this.temType = JSON.parse(JSON.stringify(this.type));
  24. }
  25. },
  26. },
  27. data() {
  28. return {
  29. showPurpose: false, //显示用印用途选项
  30. purposeArr: ["销售合同", "代付合同", "总对总协议", "渠道合同", "付款通知函", "招投标", "战略合作协议"],
  31. purpose: "",
  32. showType: false, //显示用印用途选项
  33. typeArr: ["合同章", "公章", "法人章","电子合同章"],
  34. type: [],
  35. temType: [], //临时存放选择的用印用途
  36. showServiceType: false, //显示业务类型选项
  37. ServiceTypeArr: ["新签合同", "续约合同", "补充协议",'代付合同'],
  38. ServiceType: "", //业务类型
  39. showCustome: false, //显示搜索客户名称
  40. customeName: "", //客户名称
  41. fileNum: "", //文件数
  42. remark: "", //备注
  43. CreditCode: "", //社会统一信用代码
  44. UseCompanyName: "", //实际使用方客户名称
  45. ContractId: 0, //合同id
  46. // file: {
  47. // type: "",
  48. // img: "",
  49. // url: "",
  50. // }, //上传附件 文件
  51. // 上传的附件列表 需求更改,可上传多个附件 crm-8.7
  52. fileList:[],
  53. processData: null, //流程数据
  54. radioVal: "系统合同",
  55. searchCustomeVal: "", //搜索客户输入数据
  56. searchCustomeStatus: true, //搜索客户 是否有结果
  57. searchCustomeList: [], //搜索到的客户名称列表
  58. searchContractList: [], //选择搜索中的客户后合同列表数据
  59. allCustome:{
  60. index:1,
  61. list:[],
  62. finished:false,
  63. loading:false
  64. },
  65. temCustomeName:'',
  66. //归属公司弹窗
  67. showBelongCompanyPop:false,
  68. belongCompany:'',
  69. belongCompanyOptions:[]
  70. };
  71. },
  72. methods: {
  73. async getBelongCompanyOptions(type='') {
  74. const res = await getBelongCompany()
  75. if(res.code !==200 ) return
  76. this.belongCompanyOptions = res.data || []
  77. if(type==='add'){
  78. this.belongCompany=this.belongCompanyOptions.length?this.belongCompanyOptions[0]:''
  79. }
  80. },
  81. //删除上传的附件
  82. handleDeleteCheckFile(file) {
  83. this.fileList = this.fileList.filter(item => item.url!= file.url)
  84. },
  85. //预览文件
  86. handlePreviewFiles(e) {
  87. if (e.type === "pdf" || e.type === "word") {
  88. preViewFile(e.url);
  89. } else {
  90. uni.previewImage({
  91. urls: [e.url],
  92. });
  93. }
  94. },
  95. //上传附件
  96. async handleUpload() {
  97. const res = await uploadFiles({ type: "all" });
  98. const reg = /\.(pdf)$/;
  99. const reg2 = /\.doc|\.docx$/;
  100. if (reg.test(res[0])) {
  101. this.fileList.push({
  102. type: "pdf",
  103. url: res[0],
  104. img: require("../static/pdf.png"),
  105. });
  106. } else if (reg2.test(res[0])) {
  107. this.fileList.push({
  108. type: "word",
  109. url: res[0],
  110. img: require("../static/word.png"),
  111. });
  112. } else {
  113. this.fileList.push({
  114. type: "img",
  115. url: res[0],
  116. img: res[0],
  117. });
  118. }
  119. },
  120. // 客户搜索
  121. // 先搜索出客户 再通过客户去请求出客户下面存在的合同
  122. onSearchValChange(e) {
  123. this.searchCustomeVal = e.detail;
  124. },
  125. //搜索客户
  126. async onSearch() {
  127. if (!this.searchCustomeVal) {
  128. uni.showToast({
  129. title: "请输入搜索关键字",
  130. icon: "none",
  131. });
  132. return;
  133. }
  134. this.searchContractList = [];
  135. this.searchCustomeList = [];
  136. const res = await apiSearchCustome({ Keyword: this.searchCustomeVal });
  137. if (res.code === 200) {
  138. this.searchCustomeList = res.data;
  139. if (res.data.length === 0) {
  140. this.searchCustomeStatus = false;
  141. } else {
  142. this.searchCustomeStatus = true;
  143. }
  144. }
  145. },
  146. // 搜索客户对应的合同
  147. async getContract(e) {
  148. const res = await apiSearchContract({ Keyword: e });
  149. if (res.code === 200) {
  150. if (res.data.List) {
  151. this.searchContractList = res.data.List;
  152. } else {
  153. uni.showToast({
  154. title: "此客户无合同,请重新选择",
  155. icon: "none",
  156. });
  157. }
  158. }
  159. },
  160. //归属公司选择
  161. handleComfirmBelongCmpany(e) {
  162. this.belongCompany = e.detail.value;
  163. this.showBelongCompanyPop = false;
  164. },
  165. // 选择用印用途
  166. handlePurposeConfirm(e) {
  167. this.purpose = e.detail.value;
  168. this.showPurpose = false;
  169. },
  170. //确认盖章类型
  171. handleTypeConfirm(e) {
  172. this.type = JSON.parse(JSON.stringify(this.temType));
  173. this.showType = false;
  174. this.getProcessData();
  175. },
  176. // 盖章类型变换
  177. onChangeType(e) {
  178. this.temType = e.detail;
  179. },
  180. //选择业务类型
  181. handleServiceTypeConfirm(e) {
  182. this.ServiceType = e.detail.value;
  183. this.showServiceType = false;
  184. },
  185. //合同章5 公章、法人章 6
  186. async getProcessData() {
  187. if(this.type.length===0) return
  188. let id = 0;
  189. if (this.type.includes("公章") || this.type.includes("法人章")) {
  190. id = 6;
  191. } else {
  192. id = 5;
  193. }
  194. let res = await apiFlowDetail({ FlowId: id });
  195. if (res.code === 200) {
  196. this.processData = res.data || null;
  197. }
  198. },
  199. handleAllCutomeInput(e){
  200. this.temCustomeName=e.detail.value
  201. this.allCustome.index=1
  202. this.allCustome.list=[]
  203. this.allCustome.finished=false
  204. this.allCustome.loading=false
  205. if(this.temCustomeName){
  206. this.getSearchAllCustome()
  207. }
  208. },
  209. // 搜素全部客户
  210. async getSearchAllCustome(){
  211. this.allCustome.loading=true
  212. const res=await apiSearchAllCustome({
  213. PageSize:20,
  214. CurrentIndex:this.allCustome.index,
  215. Keyword:this.temCustomeName,
  216. })
  217. this.allCustome.loading=false
  218. if(res.code===200){
  219. if(res.data){
  220. this.allCustome.list=[...this.allCustome.list,...res.data]
  221. }else{
  222. this.allCustome.finished=true
  223. }
  224. }
  225. },
  226. // 搜素全部客户弹窗触底
  227. handleScrollToLower(){
  228. if(this.allCustome.loading||this.allCustome.finished) return
  229. this.allCustome.index++
  230. this.getSearchAllCustome()
  231. },
  232. chooseAllCustomeItem(e){
  233. this.customeName=e.CompanyName
  234. this.allCustome.index=1
  235. this.allCustome.list=[]
  236. this.allCustome.finished=false
  237. this.allCustome.loading=false
  238. },
  239. // 收起搜索弹窗
  240. handleClickPage(){
  241. if(this.allCustome.list.length>0){
  242. this.allCustome.index=1
  243. this.allCustome.list=[]
  244. this.allCustome.finished=false
  245. this.allCustome.loading=false
  246. }
  247. },
  248. },
  249. };