index.vue 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147
  1. <template>
  2. <section>
  3. <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
  4. <el-form :inline="true">
  5. <el-form-item :label="$t('he-tong-lie-biao')" class="toolbar_formitem_n1"></el-form-item>
  6. <!-- 合同编号/名称 -->
  7. <el-form-item>
  8. <div style="display: flex;align-items: center;height: 40px;">
  9. <el-input v-model="keyword" class="input-with-select" @keyup.enter.native="searchFilter" :placeholder="keyword == 1 ? $t('qing-shu-ru-he-tong-bian-hao') : $t('qing-shu-ru-he-tong-ming-cheng')" clearable size="small">
  10. <el-select slot="prepend" v-model="searchField" :placeholder="$t('defaultText.pleaseChoose')" style="width:120px">
  11. <el-option :label="$t('he-tong-ming-cheng')" :value="0"></el-option>
  12. <el-option :label="$t('contractno')" :value="1"></el-option>
  13. </el-select>
  14. <el-button slot="append" @click="searchFilter" icon="el-icon-search"></el-button>
  15. </el-input>
  16. </div>
  17. </el-form-item>
  18. <!-- 合同类型 -->
  19. <el-form-item>
  20. <span style="margin-left:5px;margin-right:5px;color:#606266;">{{ $t('he-tong-lei-xing') }}</span>
  21. <el-select v-model="typeName" style="width:120px;" :placeholder="$t('defaultText.pleaseChoose')" @change="searchFilter" size="small" clearable>
  22. <el-option v-for="item in typeList" :key="item.id" :label="item.typeName" :value="item.id"></el-option>
  23. </el-select>
  24. </el-form-item>
  25. <!-- 状态 -->
  26. <el-form-item>
  27. <span style="margin-left:5px;margin-right:5px;color:#606266;">{{$t('state.states')}}</span>
  28. <el-select v-model="status" style="width:120px;" :placeholder="$t('defaultText.pleaseChoose')" @change="searchFilter" size="small" clearable>
  29. <el-option v-for="item,index in statusList" :key="item.label" :label="item.label" :value="index"></el-option>
  30. </el-select>
  31. </el-form-item>
  32. <!-- 创建时间 -->
  33. <el-form-item>
  34. <span style="margin-left:5px;margin-right:5px;color:#606266;">{{$t('creationtime')}}</span>
  35. <el-date-picker
  36. style="width:240px;"
  37. v-model="dateArray"
  38. type="daterange"
  39. size="small"
  40. range-separator="-"
  41. :start-placeholder="$t('interval')"
  42. :end-placeholder="$t('interval')"
  43. value-format="yyyy-MM-dd"
  44. clearable
  45. @change="searchFilter"
  46. ></el-date-picker>
  47. </el-form-item>
  48. <el-form-item>
  49. <span style="margin-left:5px;margin-right:5px;color:#606266;">{{ $t('xia-bi-hui-kuan-ri-qi') }}</span>
  50. <el-date-picker
  51. style="width:240px;"
  52. v-model="paymentDate"
  53. type="daterange"
  54. size="small"
  55. :start-placeholder="$t('interval')"
  56. :end-placeholder="$t('interval')"
  57. value-format="yyyy-MM-dd"
  58. clearable
  59. @change="searchFilter"
  60. ></el-date-picker>
  61. </el-form-item>
  62. <el-form-item style="float:right;">
  63. <el-dropdown>
  64. <el-link type="primary" :underline="false">{{$t('viewmore')}}<i class="el-icon-arrow-down el-icon--right"></i></el-link>
  65. <el-dropdown-menu slot="dropdown">
  66. <el-dropdown-item v-if="permissions.contractType"><el-link type="primary" :underline="false" @click="typeEdit()">{{$t('bian-ji') + $t('types')}}</el-link></el-dropdown-item>
  67. <el-dropdown-item v-if="permissions.contractImport"><el-link type="primary" :underline="false" @click="importDialog = true">{{$t('dao-ru')}}</el-link></el-dropdown-item>
  68. <el-dropdown-item v-if="permissions.contractExport"><el-link type="primary" :underline="false" @click="exportContract()">{{$t('export.export')}}</el-link></el-dropdown-item>
  69. </el-dropdown-menu>
  70. </el-dropdown>
  71. </el-form-item>
  72. <el-form-item style="float:right;" v-if="permissions.contractNew">
  73. <el-link type="primary" :underline="false" @click="newlyAdd()">{{ $t('xin-zeng-he-tong') }}</el-link>
  74. </el-form-item>
  75. </el-form>
  76. </el-col>
  77. <el-table :data="contractList" v-loading="listLoading" :height="tableHeight" border highlight-current-row>
  78. <el-table-column prop="number" :label="$t('contractno')" min-width="190"></el-table-column>
  79. <el-table-column prop="name" :label="$t('he-tong-ming-cheng')" min-width="190"></el-table-column>
  80. <el-table-column prop="amounts" :label="$t('contractamount')" min-width="135" align="right" header-align="center">
  81. <span slot-scope="scope">¥ {{scope.row.amounts ? scope.row.amounts.toFixed(2) : '0.00'}}</span>
  82. </el-table-column>
  83. <el-table-column prop="payment" :label="$t('yi-hui-kuan-jin-e')" min-width="140" align="right" header-align="center">
  84. <span slot-scope="scope">¥ {{scope.row.payment ? scope.row.payment.toFixed(2) : '0.00'}}</span>
  85. </el-table-column>
  86. <el-table-column prop="payment" :label="$t('yi-hui-kuan-jin-du')" min-width="170" align="right" header-align="center">
  87. <span slot-scope="scope">{{scope.row.payment ? (100*scope.row.payment/scope.row.amounts).toFixed(1) + '%': '0%'}}</span>
  88. </el-table-column>
  89. <el-table-column prop="nextPaymentDate" :label="$t('xia-bi-hui-kuan-ri-qi')" min-width="170" align="right" header-align="center">
  90. <span slot-scope="scope">{{scope.row.nextPaymentDate ? scope.row.nextPaymentDate : '-'}}</span>
  91. </el-table-column>
  92. <el-table-column prop="nextPaymentAmount" :label="$t('xia-bi-hui-kuan-jin-e')" min-width="120" align="right" header-align="center">
  93. <span slot-scope="scope">{{scope.row.nextPaymentAmount?'¥'+scope.row.nextPaymentAmount.toFixed(2) : '-'}}</span>
  94. </el-table-column>
  95. <el-table-column prop="typeName" :label="$t('he-tong-lei-xing')" min-width="140" align="center"></el-table-column>
  96. <el-table-column prop="status" :label="$t('state.states')" min-width="120" align="center">
  97. <template slot-scope="scope">
  98. <span :style="statusList[scope.row.status].color">{{statusList[scope.row.status].label}}</span>
  99. </template>
  100. </el-table-column>
  101. <el-table-column prop="indate" :label="$t('creationtime')" min-width="130" align="center"></el-table-column>
  102. <el-table-column width="340" :label="$t('operation')" align="left" fixed="right">
  103. <template slot-scope="scope">
  104. <el-button v-if="permissions.contractView || permissions.contractManagement" size="mini" @click="lookover(scope.row)">{{$t('cha-kan')}}</el-button>
  105. <el-button v-if="permissions.contractManagement" size="mini" @click="editContract(scope.row)" type="primary">{{$t('bian-ji')}}</el-button>
  106. <el-button v-if="permissions.contractAudit && (scope.row.status == 1 || scope.row.status == 3)" size="mini" @click="process(scope.row,0)" type="success">{{$t('btn.through')}}</el-button>
  107. <el-button v-if="permissions.contractAudit && (scope.row.status == 1 || scope.row.status == 3)" size="mini" @click="processR(scope.row,2)" type="danger">{{$t('btn.rejected')}}</el-button>
  108. </template>
  109. </el-table-column>
  110. </el-table>
  111. <el-col :span="24" class="toolbar">
  112. <el-pagination
  113. @size-change="handleSizeChange"
  114. @current-change="handleCurrentChange"
  115. :page-sizes="[20 , 50 , 80 , 100]"
  116. :page-size="size"
  117. layout="total, sizes, prev, pager, next"
  118. :total="total"
  119. style="float:right;"
  120. ></el-pagination>
  121. </el-col>
  122. <el-dialog :title="dialogTitle + $t('he-tong')" :visible.sync="addDialog" v-if="addDialog" :close-on-click-modal="false" customClass="customWidth" width="900px">
  123. <div style="height: 72vh;overflow-y: auto;overflow-x: hidden;">
  124. <el-form ref="contractForm" :model="contractForm" :rules="rules" label-width="120px" class="contractForm">
  125. <el-form-item :label="$t('contractno')">
  126. <el-input v-model="contractForm.number" :disabled="contractForm.status == 0" :maxlength="50" style="width:260px;" show-word-limit :placeholder="$t('peaseenterthe')" clearable @input="searchProject"></el-input>
  127. <span style="margin-left:20px;">{{ $t('rselatedprojects') }}</span>
  128. <el-select v-model="contractForm.projectId" filterable clearable style="width:300px;" :disabled="contractForm.status == 0">
  129. <el-option v-for="item in projectList" :key="item.id" :label="item.projectName + '\u3000' + (item.projectCode == null?'':item.projectCode)" :value="item.id" >
  130. <span style="float: left; color: #8492a6; font-size: 13px;">{{ item.projectCode }}</span>
  131. <span style="float: right;">{{ item.projectName }}</span>
  132. </el-option>
  133. </el-select>
  134. </el-form-item>
  135. <el-form-item :label="$t('he-tong-ming-cheng')" prop='name'>
  136. <el-input v-model="contractForm.name" :disabled="contractForm.status == 0" :maxlength="100" show-word-limit :placeholder="$t('peaseenterthe')" clearable></el-input>
  137. </el-form-item>
  138. <el-form-item :label="$t('contractamount')">
  139. <el-input v-model="contractForm.amounts" :disabled="contractForm.status == 0" id="contract_amount" :placeholder="$t('peaseenterthe')" @keyup.native="restrictNumber('contract_amount')" clearable>
  140. <span slot="prefix">¥</span>
  141. </el-input>
  142. </el-form-item>
  143. <el-form-item :label="$t('he-tong-lei-xing')">
  144. <el-select v-model="contractForm.typeId" :disabled="contractForm.status == 0" :placeholder="$t('defaultText.pleaseChoose')" style="width:100%">
  145. <el-option v-for="item in typeList" :key="item.id" :label="item.typeName" :value="item.id"></el-option>
  146. </el-select>
  147. </el-form-item>
  148. <el-form-item :label="$t('schedulestarttime')">
  149. <el-date-picker
  150. :disabled="contractForm.status == 0"
  151. v-model="contractForm.startDate"
  152. value-format="yyyy-MM-dd"
  153. type="date"
  154. :picker-options="{disabledDate: disabledStart}"
  155. :placeholder="$t('optiondate')">
  156. </el-date-picker>
  157. <span style="float:right;">{{$t('scheduleendtime')}}
  158. <el-date-picker
  159. :disabled="contractForm.status == 0"
  160. style="margin-left: 15px;"
  161. v-model="contractForm.endDate"
  162. value-format="yyyy-MM-dd"
  163. type="date"
  164. :picker-options="{disabledDate: disabledEnd}"
  165. :placeholder="$t('optiondate')">
  166. </el-date-picker>
  167. </span>
  168. </el-form-item>
  169. <el-form-item :label="$t('bei-zhu')">
  170. <el-input v-model="contractForm.remarks" :disabled="contractForm.status == 0" :placeholder="$t('peaseenterthe')" type="textarea" :rows="3" clearable></el-input>
  171. </el-form-item>
  172. <el-form-item :label="$t('hui-kuan-ji-hua')">
  173. <el-table :data="contractPaymentList" size="small" :key="Math.random()" :height="'300px'" show-header="false" style="margin-top:10px;">
  174. <el-table-column prop="isPayed" >
  175. <template slot-scope="scope">
  176. <el-checkbox v-model="scope.row.isPayed" >{{ $t('yi-hui-kuan') }}</el-checkbox>
  177. </template>
  178. <template slot="header" >
  179. <span style="font-size:14px;font-weight:normal;">{{ $t('shi-fou-yi-hui-kuan') }}</span>
  180. </template>
  181. </el-table-column>
  182. <el-table-column prop="payDate" :label="$t('hui-kuan-ri-qi')" width="210">
  183. <template slot-scope="scope">
  184. <div><el-date-picker type="date" v-model="scope.row.payDate" style="width:200px;" :placeholder="$t('optiondate')" value-format="yyyy-MM-dd"></el-date-picker></div>
  185. </template>
  186. </el-table-column>
  187. <el-table-column prop="amount" :label="$t('hui-kuan-jin-e')">
  188. <template slot-scope="scope">
  189. <el-input v-model="scope.row.amount" :id="'payment_amount'+scope.$index" :placeholder="$t('peaseenterthe')" maxlength="10" clearable>
  190. <span slot="prefix">¥</span>
  191. </el-input>
  192. </template>
  193. </el-table-column>
  194. <el-table-column width="80">
  195. <template slot-scope="scope">
  196. <el-button icon="el-icon-delete" size="mini" style="margin-left:10px;" @click.stop.native="deleteItem(scope.$index)"></el-button>
  197. </template>
  198. <template slot="header" >
  199. <el-link type="primary" :underline="false" @click="addItem">{{ $t('addTian') }}</el-link>
  200. </template>
  201. </el-table-column>
  202. </el-table>
  203. </el-form-item>
  204. <el-form-item label-width="0" class="contractFiles">
  205. <div class="contractFiles_title">{{ $t('fu-jian') }}
  206. <el-upload style="float:right;margin-right:5%;" ref="uploadFile" action="#" :http-request="httpRequest" :on-change="fileChange" :auto-upload="false" :show-file-list="false">
  207. <el-link type="primary">{{ $t('xin-zeng-fu-jian') }}</el-link>
  208. </el-upload>
  209. </div>
  210. <el-table :data="fileList" :header-cell-style="{'font-weight':'normal'}" highlight-current-row
  211. max-height="240" style="width: 100%;margin-top:10px;margin-bottom:15px">
  212. <el-table-column :label="$t('headerTop.serialNumber')" min-width="40" align="center">
  213. <template slot-scope="scope">
  214. <div>{{scope.$index + 1}}</div>
  215. </template>
  216. </el-table-column>
  217. <el-table-column :label="$t('filenames')" prop="name" min-width="140"></el-table-column>
  218. <!-- <el-table-column label="文件大小" min-width="60">
  219. <template slot-scope="scope">
  220. <div>{{scope.$index + 1}}</div>
  221. </template>
  222. </el-table-column> -->
  223. <el-table-column :label="$t('operation')" min-width="40">
  224. <template slot-scope="scope">
  225. <el-link @click="fileDelete(scope.row)" type="primary">{{$t('btn.delete')}}</el-link>
  226. </template>
  227. </el-table-column>
  228. </el-table>
  229. </el-form-item>
  230. </el-form>
  231. </div>
  232. <div slot="footer" class="dialog-footer;">
  233. <el-button @click.native="deleteContract()" style="float:left" v-if="dialogTitle == $t('bian-ji')">{{$t('btn.delete')}}</el-button>
  234. <el-button @click.native="addDialog = false">{{$t('btn.cancel')}}</el-button>
  235. <el-button type="primary" @click="submitInsert()" :loading="submitLoading">{{$t('btn.submit')}}</el-button>
  236. </div>
  237. </el-dialog>
  238. <el-dialog :title="$t('cha-kan-he-tong')" :visible.sync="lookoverDialog" v-if="lookoverDialog" :close-on-click-modal="false" customClass="customWidth" width="900px">
  239. <div style="height: 72vh;overflow-y: auto;overflow-x: hidden;">
  240. <el-form label-width="100px" class="lookoverContract clearfix">
  241. <el-form-item :label="$t('contractno')">
  242. {{contractForm.number}}
  243. </el-form-item>
  244. <el-form-item :label="$t('he-tong-ming-cheng')">
  245. {{contractForm.name}}
  246. </el-form-item>
  247. <el-form-item :label="$t('contractamount')">
  248. ¥ {{contractForm.amounts}}
  249. </el-form-item>
  250. <el-form-item :label="$t('he-tong-lei-xing')">
  251. {{contractForm.typeName}}
  252. </el-form-item>
  253. <el-form-item :label="$t('state.states')">
  254. {{statusList[contractForm.status].label}}
  255. </el-form-item>
  256. <el-form-item :label="$t('dismissreason')" v-if="contractForm.status == 2">
  257. <span v-if="userNameNeedTranslate == 1">
  258. <span><TranslationOpenDataText type='userName' :openid='contractForm.msg.name'></TranslationOpenDataText></span>
  259. <span>{{contractForm.msg.text}}</span>
  260. </span>
  261. <span v-else>
  262. {{contractForm.msg ? contractForm.msg : ''}}
  263. </span>
  264. </el-form-item>
  265. <el-form-item :label="$t('founder')">
  266. <span v-if="user.userNameNeedTranslate == 1"><TranslationOpenDataText type='userName' :openid='contractForm.creatorName'></TranslationOpenDataText></span>
  267. <span v-else>{{contractForm.creatorName}}</span>
  268. </el-form-item>
  269. <el-form-item :label="$t('creationtime')">
  270. {{contractForm.indate}}
  271. </el-form-item>
  272. <el-form-item :label="$t('schedulestarttime')">
  273. {{contractForm.startDate}}
  274. </el-form-item>
  275. <el-form-item :label="$t('scheduleendtime')">
  276. {{contractForm.endDate}}
  277. </el-form-item>
  278. <el-form-item style="width:100%" :label="$t('bei-zhu')">
  279. {{contractForm.remarks}}
  280. </el-form-item>
  281. <el-form-item style="width:100%" :label="$t('hui-kuan-ji-hua')">
  282. <el-table :data="contractPaymentList" size="small" :key="Math.random()" :height="'300px'" show-header="false" style="margin-top:10px;">
  283. <el-table-column prop="isPayed" >
  284. <template slot-scope="scope">
  285. {{ scope.row.isPayed?$t('yi-hui-kuan'):$t('wei-hui-kuan') }}
  286. </template>
  287. <template slot="header" >
  288. <span style="font-size:14px;font-weight:normal;">{{ $t('shi-fou-yi-hui-kuan') }}</span>
  289. </template>
  290. </el-table-column>
  291. <el-table-column prop="payDate" :label="$t('hui-kuan-ri-qi')" width="210">
  292. <template slot-scope="scope">
  293. <div>{{ scope.row.payDate }}</div>
  294. </template>
  295. </el-table-column>
  296. <el-table-column prop="amount" :label="$t('hui-kuan-jin-e')">
  297. <template slot-scope="scope">
  298. <div>{{ scope.row.amount }}</div>
  299. </template>
  300. </el-table-column>
  301. </el-table>
  302. </el-form-item>
  303. <el-form-item label-width="0" class="contractFiles">
  304. <div class="contractFiles_title">{{ $t('fu-jian') }}</div>
  305. <el-table :data="fileList" :header-cell-style="{'font-weight':'normal'}" highlight-current-row
  306. max-height="240" style="width: 100%;margin-top:10px;margin-bottom:30px">
  307. <el-table-column :label="$t('headerTop.serialNumber')" min-width="40" align="center">
  308. <template slot-scope="scope">
  309. <div>{{scope.$index + 1}}</div>
  310. </template>
  311. </el-table-column>
  312. <el-table-column :label="$t('filenames')" prop="name" min-width="140"></el-table-column>
  313. <!-- <el-table-column label="文件大小" min-width="60">
  314. <template slot-scope="scope">
  315. <div>{{scope.$index + 1}}</div>
  316. </template>
  317. </el-table-column> -->
  318. <el-table-column :label="$t('operation')" min-width="40">
  319. <template slot-scope="scope">
  320. <el-link @click="fileDownload(scope.row)" type="primary">{{$t('other.download')}}</el-link>
  321. </template>
  322. </el-table-column>
  323. </el-table>
  324. </el-form-item>
  325. </el-form>
  326. </div>
  327. </el-dialog>
  328. <el-dialog :title="$t('he-tong-lei-xing-guan-li')" :visible.sync="typeDialog" v-if="typeDialog" customClass="customWidth" width="500px">
  329. <el-table :data="typeList" highlight-current-row height="400" style="width: 100%;">
  330. <el-table-column type="index" width="60" :label="$t('headerTop.serialNumber')">
  331. <template slot-scope="scope">{{ scope.$index + 1 }}</template>
  332. </el-table-column>
  333. <el-table-column prop="typeName"></el-table-column>
  334. <el-table-column :label="$t('operation')" width="150">
  335. <template slot-scope="scope">
  336. <el-button size="small" type="primary" @click="typeItemEdit(scope.row)">{{$t('bian-ji')}}</el-button>
  337. <el-button size="small" type="danger" @click="typeItemDelete(scope.row)">{{$t('btn.delete')}}</el-button>
  338. </template>
  339. </el-table-column>
  340. </el-table>
  341. <div slot="footer" class="dialog-footer;">
  342. <el-button type="primary" @click="typeDialog = false">{{$t('Shutdown')}}</el-button>
  343. <el-button type="primary" @click="typeItemAdd()">{{ $t('xin-zeng-he-tong-lei-xing') }}</el-button>
  344. </div>
  345. <el-dialog :title="typeTitle == this.$t('add') ? $t('xin-zeng-he-tong-lei-xing') : $t('bian-ji-he-tong-lei-xing')" :visible.sync="typeItemDialog" v-if="typeItemDialog" append-to-body width="400px">
  346. <div style="height: 12vh;overflow-y: auto;overflow-x: hidden;">
  347. <el-input v-model="typeItemForm.typeName" :maxlength="200"></el-input>
  348. </div>
  349. <div slot="footer" class="dialog-footer;">
  350. <el-button type="primary" @click="typeItemDialog = false">{{$t('btn.cancel')}}</el-button>
  351. <el-button type="primary" @click="typeItemSubmit()">{{$t('btn.determine')}}</el-button>
  352. </div>
  353. </el-dialog>
  354. </el-dialog>
  355. <el-dialog :title="$t('dao-ru-he-tong')" :visible.sync="importDialog" v-if="importDialog" width="30%">
  356. <!-- 模板? -->
  357. <p>1. {{$t('other.download')}}
  358. <el-link type="primary" style="margin-left:5px;" :underline="false" :href="'./upload/'+$t('he-tong-guan-li-dao-ru-mo-ban')+'.xlsx'" :download="$t('he-tong-guan-li-dao-ru-mo-ban')+'.xlsx'">{{$t('he-tong-guan-li-dao-ru-mo-ban')+ '.xlsx'}}</el-link>
  359. </p>
  360. <div slot="footer" class="dialog-footer" style="text-align:center;">
  361. <el-upload ref="upload" action="#" :limit="1" :http-request="importContract" :show-file-list="false">
  362. <el-button type="primary" :loading="importLoading">{{ $t('dao-ru-he-tong') }}</el-button>
  363. </el-upload>
  364. </div>
  365. </el-dialog>
  366. <el-dialog :title="$t('defaultText.pleaseEnterTheReason')" v-if="denyReasonDialog" :visible.sync="denyReasonDialog" :close-on-click-modal="false" customClass="customWidth" width="500px">
  367. <div>
  368. <el-input type="textarea" v-model="denyReason" rows="2" :placeholder="$t('reasonforyourdecisiontoreject')" />
  369. </div>
  370. <div slot="footer" class="dialog-footer">
  371. <el-button @click="denyReasonDialog = false" >{{$t('btn.cancel')}}</el-button>
  372. <el-button type="primary" @click="process(null,2)" >{{$t('btn.submit')}}</el-button>
  373. </div>
  374. </el-dialog>
  375. </section>
  376. </template>
  377. <script>
  378. export default {
  379. data() {
  380. return {
  381. paymentDate: null,
  382. contractPaymentList: [],
  383. user: JSON.parse(sessionStorage.getItem("user")),
  384. permissions: JSON.parse(sessionStorage.getItem("permissions")),
  385. searchField: 0,
  386. keyword: '',
  387. typeName: '',
  388. status: '',
  389. dateArray: [],
  390. typeList: [],
  391. contractList: [],
  392. listLoading: false,
  393. statusList: [
  394. {label:this.$t('state.approved'),color: 'color:#67c23a;'},
  395. {label:this.$t('state.WaitingAudit'),color: 'color:#e6a23c;'},
  396. {label:this.$t('state.rejected'),color: 'color:#f56c6c;'},
  397. // {label:this.$t('other.importWaitingForReview'),color: 'color:#e6a23c;'},
  398. ],
  399. typeDialog: false,
  400. typeTitle: this.$t('add'),
  401. typeItemDialog: false,
  402. typeItemForm: {typeName: ''},
  403. denyReasonDialog: false,
  404. denyReason: '',
  405. denyrow: null,
  406. dialogTitle: this.$t('add'),
  407. addDialog: false,
  408. lookoverDialog: false,
  409. submitLoading: false,
  410. contractForm: {
  411. number: '',
  412. name: '',
  413. amounts: '',
  414. typeId: null,
  415. remarks: '',
  416. startDate: '',
  417. endDate: ''
  418. },
  419. rules:{
  420. name: [{ required: true, message: this.$t('pleaseentername'), trigger: "blur" }],
  421. },
  422. fileList: [],
  423. importDialog: false,
  424. importLoading: false,
  425. projectList:[],
  426. page: 1,
  427. size: 20,
  428. total: 0,
  429. tableHeight: 0
  430. }
  431. },
  432. created() {
  433. let height = window.innerHeight;
  434. this.tableHeight = height - 180;
  435. const that = this;
  436. window.onresize = function temp() {
  437. that.tableHeight = window.innerHeight - 185;
  438. };
  439. },
  440. mounted() {
  441. this.getProjectList();
  442. this.getContractList()
  443. this.getContractType()
  444. },
  445. methods: {
  446. // test(row){
  447. // console.log('test',row);
  448. // // this.$refs.uploadFile.submit()
  449. // },
  450. restrictNumber(targetId) {
  451. let inpu = document.getElementById(targetId);
  452. inpu.value = inpu.value.replace(/[^\d.]/g, ""); //仅保留数字和"."
  453. inpu.value = inpu.value.replace(/\.{2,}/g, "."); //两个连续的"."仅保留第一个"."
  454. inpu.value = inpu.value.replace(".", "$#*").replace(/\./g,'').replace('$#*','.');//去除其他"."
  455. inpu.value = inpu.value.replace(/^(\d+)\.(\d\d).*$/, '$1.$2');;//限制只能输入两个小数
  456. if (inpu.value.indexOf(".") < 0 && inpu.value != "") { //首位是0的话去掉
  457. inpu.value = parseFloat(inpu.value);
  458. }
  459. if(inpu.value.split('.')[0].length > 9){
  460. inpu.value = inpu.value.split('.')[0].substring(0,9) + (inpu.value.split('.')[1] ? '.' + inpu.value.split('.')[1] : '')
  461. this.contractForm.amounts = inpu.value
  462. }
  463. },
  464. searchProject() {
  465. console.log(this.contractForm.number);
  466. //按合同编号去匹配项目编号,自动加载关联项目
  467. if (this.contractForm.number) {
  468. var matchItem = this.projectList.filter(p=>p.projectCode == this.contractForm.number);
  469. if (matchItem.length > 0) {
  470. this.contractForm.projectId = matchItem[0].id;
  471. this.contractForm.name = matchItem[0].projectName;
  472. this.contractForm.amount = matchItem[0].contractAmount;
  473. }
  474. }
  475. },
  476. //删除合同回款情况
  477. deleteItem(index) {
  478. this.contractPaymentList.splice(index,1);
  479. },
  480. //添加合同回款情况
  481. addItem() {
  482. let p = 0;
  483. this.contractPaymentList.push( { contractId:this.contractForm.id, isPayed:false,payDate: null, amount:0.0});
  484. },
  485. getProjectList() {
  486. this.http.post('/contract/getProjectList',{},
  487. res => {
  488. if(res.code == 'ok'){
  489. this.projectList = res.data;
  490. }else{
  491. this.$message({
  492. message: res.msg,
  493. type: 'error'
  494. })
  495. }
  496. },err => {
  497. this.$message({
  498. message: err,
  499. type: 'error'
  500. })
  501. })
  502. },
  503. disabledStart(date){
  504. if(this.contractForm.endDate){
  505. if(date > new Date(this.contractForm.endDate)){
  506. return true
  507. }else{
  508. return false
  509. }
  510. }else{
  511. return false
  512. }
  513. },
  514. disabledEnd(date){
  515. if(this.contractForm.startDate){
  516. if(date < new Date(this.contractForm.startDate)){
  517. return true
  518. }else{
  519. return false
  520. }
  521. }else{
  522. return false
  523. }
  524. },
  525. searchFilter(){
  526. this.page = 1
  527. this.getContractList()
  528. },
  529. handleSizeChange(val){
  530. this.size = val
  531. this.page = 1
  532. this.getContractList()
  533. },
  534. handleCurrentChange(val){
  535. this.page = val;
  536. this.getContractList()
  537. },
  538. importContract(item){
  539. let str = item.file.name.split('.')
  540. let format = str[str.length - 1];
  541. if(format != "xls" && format != "xlsx"){
  542. this.$message({
  543. message: this.$t('other.PleaseselecttheXLSorXLSXfile'),
  544. type: 'error'
  545. })
  546. }else{
  547. this.importLoading = true
  548. let formData = new FormData();
  549. formData.append("file", item.file);
  550. formData.append("userId", this.user.id);
  551. this.http.uploadFile('/contract/importContract',formData,
  552. res => {
  553. this.$refs.upload.clearFiles();
  554. this.importLoading = false;
  555. if(res.code == 'ok'){
  556. this.importDialog = false
  557. this.$message({
  558. message: this.$t('other.importSuccess'),
  559. type: 'success'
  560. })
  561. this.getContractList()
  562. }else{
  563. this.$message({
  564. message: res.msg,
  565. type: 'error'
  566. })
  567. }
  568. },err => {
  569. this.importLoading = false;
  570. this.$message({
  571. message: err,
  572. type: 'error'
  573. })
  574. })
  575. }
  576. },
  577. exportContract(){
  578. let parameter = {}
  579. if(this.typeName){
  580. parameter.typeName = this.typeName
  581. }
  582. if(this.keyword){
  583. if(this.searchField){
  584. parameter.number = this.keyword
  585. }else{
  586. parameter.name = this.keyword
  587. }
  588. }
  589. if(this.status !== ''){
  590. parameter.status = this.status
  591. }
  592. if(this.dateArray && this.dateArray.length == 2){
  593. parameter.startDate = this.dateArray[0]
  594. parameter.endDate = this.dateArray[1]
  595. }
  596. this.http.post('/contract/ExportContract',parameter,
  597. res => {
  598. if(res.code == 'ok'){
  599. let filePath = res.data;
  600. const a = document.createElement('a'); // 创建a标签
  601. a.setAttribute('download', this.$t('he-tong-dao-chu') + '.xlsx');// download属性
  602. a.setAttribute('href', filePath);// href链接
  603. a.click(); //自执行点击事件
  604. a.remove();
  605. }else{
  606. this.$message({
  607. message: res.msg,
  608. type: 'error'
  609. })
  610. }
  611. },err => {
  612. this.$message({
  613. message: err,
  614. type: 'error'
  615. })
  616. })
  617. },
  618. typeEdit(){
  619. this.typeDialog = true
  620. },
  621. typeItemAdd(){
  622. if(this.typeList.length == 20){
  623. this.$message({
  624. message: this.$t('he-tong-lei-xing-zui-duo-zhi-neng-chuang-jian-20-ge'),
  625. type: 'error'
  626. })
  627. return
  628. }
  629. this.typeTitle = this.$t('add')
  630. this.typeItemForm = {typeName: ''}
  631. this.typeItemDialog = true
  632. },
  633. typeItemEdit(row){
  634. this.typeTitle = this.$t('bian-ji')
  635. this.typeItemForm = JSON.parse(JSON.stringify(row))
  636. this.typeItemDialog = true
  637. },
  638. typeItemDelete(row){
  639. this.$confirm(this.$t('que-ding-yao-shan-chu-ci-tiao-he-tong-lei-xing-ma'), this.$t('other.prompts'), {
  640. confirmButtonText: this.$t('btn.determine'),
  641. cancelButtonText: this.$t('btn.cancel'),
  642. type: 'warning'
  643. }).then(() => {
  644. this.http.post('/contractType/deleteContractType',{
  645. deleteId: row.id
  646. },res => {
  647. if(res.code == 'ok'){
  648. this.getContractType()
  649. this.$message({
  650. type: 'success',
  651. message: this.$t('message.successfullyDeleted') + '!'
  652. });
  653. }else{
  654. this.$message({
  655. type: 'error',
  656. message: res.msg
  657. });
  658. }
  659. },err => {
  660. this.$message({
  661. type: 'error',
  662. message: err
  663. });
  664. })
  665. }).catch(() => {
  666. this.$message({
  667. type: 'info',
  668. message: this.$t('thedeletionhasbeencancelled')
  669. });
  670. });
  671. },
  672. typeItemSubmit(){
  673. this.http.post('/contractType/changeContractType',this.typeItemForm,
  674. res => {
  675. if(res.code == 'ok'){
  676. this.typeItemDialog = false
  677. this.getContractType()
  678. this.$message({
  679. message: this.typeTitle == this.$t('add') ? this.$t('newsuccess') : this.$t('editsuccess'),
  680. type: 'success'
  681. })
  682. }else{
  683. this.$message({
  684. message: res.msg,
  685. type: 'error'
  686. })
  687. }
  688. },err => {
  689. this.$message({
  690. message: err,
  691. type: 'error'
  692. })
  693. })
  694. },
  695. newlyAdd(){
  696. this.dialogTitle = this.$t('add')
  697. this.contractForm = {
  698. number: '',
  699. name: '',
  700. amounts: '',
  701. typeId: null,
  702. remarks: '',
  703. startDate: '',
  704. endDate: ''
  705. }
  706. this.contractPaymentList = [];
  707. this.fileList = []
  708. this.addDialog = true
  709. },
  710. editContract(row){
  711. this.dialogTitle = this.$t('bian-ji')
  712. this.contractForm = JSON.parse(JSON.stringify(row))
  713. this.fileList = this.contractForm.files ? this.contractForm.files : []
  714. for(let i in this.fileList){
  715. this.fileList[i].name = this.fileList[i].documentName
  716. }
  717. this.addDialog = true;
  718. this.getContractPaymentList();
  719. },
  720. getContractPaymentList() {
  721. this.contractPaymentList = [];
  722. this.http.post('/contract-payment/getList',{contractId: this.contractForm.id},
  723. res => {
  724. if(res.code == 'ok'){
  725. this.contractPaymentList = res.data;
  726. }else{
  727. this.$message({
  728. message: res.msg,
  729. type: 'error'
  730. })
  731. }
  732. },err => {
  733. this.$message({
  734. message: err,
  735. type: 'error'
  736. })
  737. })
  738. },
  739. deleteContract(){
  740. this.$confirm(this.$t('que-ding-yao-shan-chu-gai-he-tong-ma'), this.$t('other.prompts'), {
  741. confirmButtonText: this.$t('btn.determine'),
  742. cancelButtonText: this.$t('btn.cancel'),
  743. type: 'warning'
  744. }).then(() => {
  745. this.http.post('/contract/deleteContract',{
  746. id: this.contractForm.id
  747. },res => {
  748. if(res.code == 'ok'){
  749. this.addDialog = false
  750. this.getContractList()
  751. this.$message({
  752. type: 'success',
  753. message: this.$t('message.successfullyDeleted') + '!'
  754. });
  755. }else{
  756. this.$message({
  757. type: 'error',
  758. message: res.msg
  759. });
  760. }
  761. },err => {
  762. this.$message({
  763. type: 'error',
  764. message: err
  765. });
  766. })
  767. }).catch(() => {
  768. this.$message({
  769. type: 'info',
  770. message: this.$t('thedeletionhasbeencancelled')
  771. });
  772. });
  773. },
  774. processR(row,status){
  775. this.denyReasonDialog = true
  776. this.denyrowId = row.id
  777. this.denyReason = ''
  778. },
  779. process(row,status){
  780. let parameter
  781. if(status == 2){
  782. parameter = {
  783. id: this.denyrowId,
  784. status: status,
  785. msg: this.denyReason
  786. }
  787. }else{
  788. parameter = {
  789. id: row.id,
  790. status: status
  791. }
  792. }
  793. this.$confirm(this.$t('que-ren-shen-he-tong-guo-ma-tong-guo-hou-he-tong-ji-ben-xin-xi-wu-fa-xiu-gai'), this.$t('other.prompts'), {
  794. confirmButtonText: this.$t('btn.determine'),
  795. cancelButtonText: this.$t('btn.cancel'),
  796. type: 'warning'
  797. }).then(() => {
  798. this.http.post('/contract/processContract',parameter,
  799. res => {
  800. if(res.code == 'ok'){
  801. this.getContractList()
  802. this.denyReasonDialog = false
  803. this.$message({
  804. message: status == 0 ? this.$t('state.alreadyPassed') : this.$t('state.rejected'),
  805. type: 'success'
  806. })
  807. }else{
  808. this.$message({
  809. message: res.msg,
  810. type: 'error'
  811. })
  812. }
  813. },err => {
  814. this.$message({
  815. message: err,
  816. type: 'error'
  817. })
  818. })
  819. });
  820. },
  821. lookover(row){
  822. console.log('lookover',row);
  823. if(this.user.userNameNeedTranslate == 1) {
  824. let obj = {name: '',text: ''}
  825. if (row.msg) {
  826. let match = row.msg.match(/\$userName=(.*?)\$(.*)/);
  827. if (match) {
  828. obj.name = match[1];
  829. obj.text = match[2];
  830. } else {
  831. obj.text = row.msg;
  832. }
  833. }
  834. // if(row.msg.indexOf('$userName=') != '-1') {
  835. // let str = row.msg.split('$userName=')[1]
  836. // let arr = str.split('$')
  837. // obj.name = arr[0]
  838. // obj.text = arr[1]
  839. // } else {
  840. // obj.text = row.msg
  841. // }
  842. row.msg = obj
  843. this.contractForm = row
  844. } else {
  845. this.contractForm = row
  846. }
  847. this.fileList = this.contractForm.files ? this.contractForm.files : []
  848. for(let i in this.fileList){
  849. this.fileList[i].name = this.fileList[i].documentName
  850. }
  851. this.lookoverDialog = true;
  852. this.getContractPaymentList();
  853. },
  854. submitInsert(){
  855. this.$refs.contractForm.validate(valid => {
  856. if (valid) {
  857. //校验回款日期和金额
  858. var totalPayment = 0.0;
  859. for (var i = 0; i < this.contractPaymentList.length; i++) {
  860. if (!this.contractPaymentList[i].payDate) {
  861. this.$message({
  862. message: this.$t('hui-kuan-ri-qi-bu-neng-wei-kong'),
  863. type: 'error'
  864. })
  865. return;
  866. }
  867. if (!this.contractPaymentList[i].amount) {
  868. this.$message({
  869. message: this.$t('hui-kuan-jinebu-neng-wei-0'),
  870. type: 'error'
  871. })
  872. return;
  873. }
  874. totalPayment += parseFloat(this.contractPaymentList[i].amount);
  875. }
  876. if (totalPayment > parseFloat(this.contractForm.amounts)) {
  877. this.$message({
  878. message: this.$t('zong-hui-kuan-jinebu-de-da-yu-he-tong-jin-e'),
  879. type: 'error'
  880. })
  881. return;
  882. }
  883. this.submitLoading = true
  884. delete this.contractForm.files
  885. this.contractForm.paymentListStr = JSON.stringify(this.contractPaymentList);
  886. this.http.post(this.dialogTitle == this.$t('add') ? '/contract/addContract' : '/contract/editContract',this.contractForm,
  887. res => {
  888. this.submitLoading = false
  889. this.addDialog = false
  890. if(res.code == 'ok'){
  891. this.$message({
  892. message: res.msg,
  893. type: 'success'
  894. })
  895. if(this.dialogTitle == this.$t('add')){
  896. this.contractForm.id = res.data
  897. }
  898. this.submitFile()
  899. }else{
  900. this.$message({
  901. message: res.msg,
  902. type: 'error'
  903. })
  904. }
  905. },err => {
  906. this.submitLoading = false
  907. this.addDialog = false
  908. this.$message({
  909. message: err,
  910. type: 'error'
  911. })
  912. })
  913. }
  914. })
  915. },
  916. fileChange(file,fileList){
  917. // console.log('fileChange',file,fileList);
  918. file.needUpload = true
  919. this.fileList.push(file)
  920. },
  921. fileDelete(row){
  922. // console.log(row,this.fileList);
  923. this.$confirm(this.$t('que-ding-yao-shan-chu-gai-wen-jian-ma'), this.$t('other.prompts'), {
  924. confirmButtonText: this.$t('btn.determine'),
  925. cancelButtonText: this.$t('btn.cancel'),
  926. type: 'warning'
  927. }).then(() => {
  928. if(row.uid){
  929. for(let i in this.fileList){
  930. if(this.fileList[i].uid && this.fileList[i].uid == row.uid){
  931. this.fileList.splice(i,1)
  932. }
  933. }
  934. }else{
  935. this.http.post('/contract-document/fileDelete',{
  936. contractId: this.contractForm.id,
  937. fileIds: [row.id]
  938. },res => {
  939. if(res.code == 'ok'){
  940. this.getContractList()
  941. this.fileList.filter(item => !item.id || item.id != row.id)
  942. this.$message({
  943. type: 'success',
  944. message: this.$t('message.successfullyDeleted') + '!'
  945. });
  946. }else{
  947. this.$message({
  948. type: 'error',
  949. message: res.msg
  950. });
  951. }
  952. },err => {
  953. this.$message({
  954. type: 'error',
  955. message: err
  956. });
  957. })
  958. }
  959. }).catch(() => {
  960. this.$message({
  961. type: 'info',
  962. message: this.$t('thedeletionhasbeencancelled')
  963. });
  964. });
  965. },
  966. fileDownload(row){
  967. this.http.downloadFile('/contract-document/fileDown',{
  968. contractId: this.contractForm.id,
  969. fileId: row.id
  970. },row.name,err=>{
  971. this.$message({
  972. message: err,
  973. type: 'error'
  974. })
  975. })
  976. },
  977. submitFile(){
  978. // console.log('submitFile',this.fileList);
  979. let formData = new FormData();
  980. for(let i in this.fileList){
  981. if(this.fileList[i].needUpload){
  982. formData.append("file", this.fileList[i].raw);
  983. }
  984. }
  985. formData.append("ContractId", this.contractForm.id);
  986. this.http.uploadFile('/contract-document/fileUpload',formData,
  987. res => {
  988. if(res.code == 'ok'){
  989. this.getContractList()
  990. }else{
  991. this.$message({
  992. message: res.msg,
  993. type: 'error'
  994. })
  995. }
  996. },err => {
  997. this.$message({
  998. message: err,
  999. type: 'error'
  1000. })
  1001. })
  1002. },
  1003. getContractType(){
  1004. this.http.post('/contractType/getContractType',{},
  1005. res=>{
  1006. if(res.code=='ok'){
  1007. this.typeList = res.data
  1008. }else{
  1009. this.$message({
  1010. message: res.msg,
  1011. type: 'error'
  1012. })
  1013. }
  1014. },err=>{
  1015. this.$message({
  1016. message: err,
  1017. type: 'error'
  1018. })
  1019. })
  1020. },
  1021. getContractList(){
  1022. // pageIndex,pageSize,number,name,typeName,status,startDate,endDate
  1023. let parameter = {
  1024. pageIndex: this.page,
  1025. pageSize: this.size,
  1026. }
  1027. if(this.typeName){
  1028. parameter.typeName = this.typeName
  1029. }
  1030. if(this.keyword){
  1031. if(this.searchField){
  1032. parameter.number = this.keyword
  1033. }else{
  1034. parameter.name = this.keyword
  1035. }
  1036. }
  1037. if(this.status !== ''){
  1038. parameter.status = this.status
  1039. }
  1040. if(this.dateArray && this.dateArray.length == 2){
  1041. parameter.startDate = this.dateArray[0]
  1042. parameter.endDate = this.dateArray[1]
  1043. }
  1044. if(this.paymentDate && this.paymentDate.length == 2){
  1045. parameter.paymentStartDate = this.paymentDate[0]
  1046. parameter.paymentEndDate = this.paymentDate[1]
  1047. }
  1048. this.listLoading = true
  1049. this.http.post('/contract/getContractPage',parameter,
  1050. res => {
  1051. this.listLoading = false
  1052. if(res.code == 'ok'){
  1053. this.contractList = res.data.data
  1054. this.total = res.data.total
  1055. }else{
  1056. this.$message({
  1057. message: res.msg,
  1058. type: 'error'
  1059. })
  1060. }
  1061. },err => {
  1062. this.listLoading = false
  1063. this.$message({
  1064. message: err,
  1065. type: 'error'
  1066. })
  1067. })
  1068. }
  1069. },
  1070. }
  1071. </script>
  1072. <style>
  1073. .lookoverContract{
  1074. margin-top: 30px;
  1075. }
  1076. .lookoverContract .el-form-item{
  1077. width: 50%;
  1078. float: left;
  1079. }
  1080. .lookoverContract .el-form-item__label{
  1081. font-weight: 600;
  1082. }
  1083. .lookoverContract .contractFiles{
  1084. width: 100%;
  1085. }
  1086. .lookoverContract .contractFiles_title{
  1087. margin-left: 5%;
  1088. font-size: 16px;
  1089. line-height: 20px;
  1090. margin-top: 16px;
  1091. }
  1092. .contractForm{
  1093. margin-top: 30px;
  1094. }
  1095. .contractForm .el-form-item{
  1096. width: 90%;
  1097. }
  1098. .contractForm .contractFiles{
  1099. width: 100%;
  1100. }
  1101. .contractForm .contractFiles_title{
  1102. margin-left: 5%;
  1103. font-size: 16px;
  1104. line-height: 20px;
  1105. margin-top: 16px;
  1106. }
  1107. </style>