contractManagement.vue 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148
  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. delete this.contractForm.customData;
  714. this.fileList = this.contractForm.files ? this.contractForm.files : []
  715. for(let i in this.fileList){
  716. this.fileList[i].name = this.fileList[i].documentName
  717. }
  718. this.addDialog = true;
  719. this.getContractPaymentList();
  720. },
  721. getContractPaymentList() {
  722. this.contractPaymentList = [];
  723. this.http.post('/contract-payment/getList',{contractId: this.contractForm.id},
  724. res => {
  725. if(res.code == 'ok'){
  726. this.contractPaymentList = res.data;
  727. }else{
  728. this.$message({
  729. message: res.msg,
  730. type: 'error'
  731. })
  732. }
  733. },err => {
  734. this.$message({
  735. message: err,
  736. type: 'error'
  737. })
  738. })
  739. },
  740. deleteContract(){
  741. this.$confirm(this.$t('que-ding-yao-shan-chu-gai-he-tong-ma'), this.$t('other.prompts'), {
  742. confirmButtonText: this.$t('btn.determine'),
  743. cancelButtonText: this.$t('btn.cancel'),
  744. type: 'warning'
  745. }).then(() => {
  746. this.http.post('/contract/deleteContract',{
  747. id: this.contractForm.id
  748. },res => {
  749. if(res.code == 'ok'){
  750. this.addDialog = false
  751. this.getContractList()
  752. this.$message({
  753. type: 'success',
  754. message: this.$t('message.successfullyDeleted') + '!'
  755. });
  756. }else{
  757. this.$message({
  758. type: 'error',
  759. message: res.msg
  760. });
  761. }
  762. },err => {
  763. this.$message({
  764. type: 'error',
  765. message: err
  766. });
  767. })
  768. }).catch(() => {
  769. this.$message({
  770. type: 'info',
  771. message: this.$t('thedeletionhasbeencancelled')
  772. });
  773. });
  774. },
  775. processR(row,status){
  776. this.denyReasonDialog = true
  777. this.denyrowId = row.id
  778. this.denyReason = ''
  779. },
  780. process(row,status){
  781. let parameter
  782. if(status == 2){
  783. parameter = {
  784. id: this.denyrowId,
  785. status: status,
  786. msg: this.denyReason
  787. }
  788. }else{
  789. parameter = {
  790. id: row.id,
  791. status: status
  792. }
  793. }
  794. 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'), {
  795. confirmButtonText: this.$t('btn.determine'),
  796. cancelButtonText: this.$t('btn.cancel'),
  797. type: 'warning'
  798. }).then(() => {
  799. this.http.post('/contract/processContract',parameter,
  800. res => {
  801. if(res.code == 'ok'){
  802. this.getContractList()
  803. this.denyReasonDialog = false
  804. this.$message({
  805. message: status == 0 ? this.$t('state.alreadyPassed') : this.$t('state.rejected'),
  806. type: 'success'
  807. })
  808. }else{
  809. this.$message({
  810. message: res.msg,
  811. type: 'error'
  812. })
  813. }
  814. },err => {
  815. this.$message({
  816. message: err,
  817. type: 'error'
  818. })
  819. })
  820. });
  821. },
  822. lookover(row){
  823. console.log('lookover',row);
  824. if(this.user.userNameNeedTranslate == 1) {
  825. let obj = {name: '',text: ''}
  826. if (row.msg) {
  827. let match = row.msg.match(/\$userName=(.*?)\$(.*)/);
  828. if (match) {
  829. obj.name = match[1];
  830. obj.text = match[2];
  831. } else {
  832. obj.text = row.msg;
  833. }
  834. }
  835. // if(row.msg.indexOf('$userName=') != '-1') {
  836. // let str = row.msg.split('$userName=')[1]
  837. // let arr = str.split('$')
  838. // obj.name = arr[0]
  839. // obj.text = arr[1]
  840. // } else {
  841. // obj.text = row.msg
  842. // }
  843. row.msg = obj
  844. this.contractForm = row
  845. } else {
  846. this.contractForm = row
  847. }
  848. this.fileList = this.contractForm.files ? this.contractForm.files : []
  849. for(let i in this.fileList){
  850. this.fileList[i].name = this.fileList[i].documentName
  851. }
  852. this.lookoverDialog = true;
  853. this.getContractPaymentList();
  854. },
  855. submitInsert(){
  856. this.$refs.contractForm.validate(valid => {
  857. if (valid) {
  858. //校验回款日期和金额
  859. var totalPayment = 0.0;
  860. for (var i = 0; i < this.contractPaymentList.length; i++) {
  861. if (!this.contractPaymentList[i].payDate) {
  862. this.$message({
  863. message: this.$t('hui-kuan-ri-qi-bu-neng-wei-kong'),
  864. type: 'error'
  865. })
  866. return;
  867. }
  868. if (!this.contractPaymentList[i].amount) {
  869. this.$message({
  870. message: this.$t('hui-kuan-jinebu-neng-wei-0'),
  871. type: 'error'
  872. })
  873. return;
  874. }
  875. totalPayment += parseFloat(this.contractPaymentList[i].amount);
  876. }
  877. if (totalPayment > parseFloat(this.contractForm.amounts)) {
  878. this.$message({
  879. message: this.$t('zong-hui-kuan-jinebu-de-da-yu-he-tong-jin-e'),
  880. type: 'error'
  881. })
  882. return;
  883. }
  884. this.submitLoading = true
  885. delete this.contractForm.files
  886. this.contractForm.paymentListStr = JSON.stringify(this.contractPaymentList);
  887. this.http.post(this.dialogTitle == this.$t('add') ? '/contract/addContract' : '/contract/editContract',this.contractForm,
  888. res => {
  889. this.submitLoading = false
  890. this.addDialog = false
  891. if(res.code == 'ok'){
  892. this.$message({
  893. message: res.msg,
  894. type: 'success'
  895. })
  896. if(this.dialogTitle == this.$t('add')){
  897. this.contractForm.id = res.data
  898. }
  899. this.submitFile()
  900. }else{
  901. this.$message({
  902. message: res.msg,
  903. type: 'error'
  904. })
  905. }
  906. },err => {
  907. this.submitLoading = false
  908. this.addDialog = false
  909. this.$message({
  910. message: err,
  911. type: 'error'
  912. })
  913. })
  914. }
  915. })
  916. },
  917. fileChange(file,fileList){
  918. // console.log('fileChange',file,fileList);
  919. file.needUpload = true
  920. this.fileList.push(file)
  921. },
  922. fileDelete(row){
  923. // console.log(row,this.fileList);
  924. this.$confirm(this.$t('que-ding-yao-shan-chu-gai-wen-jian-ma'), this.$t('other.prompts'), {
  925. confirmButtonText: this.$t('btn.determine'),
  926. cancelButtonText: this.$t('btn.cancel'),
  927. type: 'warning'
  928. }).then(() => {
  929. if(row.uid){
  930. for(let i in this.fileList){
  931. if(this.fileList[i].uid && this.fileList[i].uid == row.uid){
  932. this.fileList.splice(i,1)
  933. }
  934. }
  935. }else{
  936. this.http.post('/contract-document/fileDelete',{
  937. contractId: this.contractForm.id,
  938. fileIds: [row.id]
  939. },res => {
  940. if(res.code == 'ok'){
  941. this.getContractList()
  942. this.fileList.filter(item => !item.id || item.id != row.id)
  943. this.$message({
  944. type: 'success',
  945. message: this.$t('message.successfullyDeleted') + '!'
  946. });
  947. }else{
  948. this.$message({
  949. type: 'error',
  950. message: res.msg
  951. });
  952. }
  953. },err => {
  954. this.$message({
  955. type: 'error',
  956. message: err
  957. });
  958. })
  959. }
  960. }).catch(() => {
  961. this.$message({
  962. type: 'info',
  963. message: this.$t('thedeletionhasbeencancelled')
  964. });
  965. });
  966. },
  967. fileDownload(row){
  968. this.http.downloadFile('/contract-document/fileDown',{
  969. contractId: this.contractForm.id,
  970. fileId: row.id
  971. },row.name,err=>{
  972. this.$message({
  973. message: err,
  974. type: 'error'
  975. })
  976. })
  977. },
  978. submitFile(){
  979. // console.log('submitFile',this.fileList);
  980. let formData = new FormData();
  981. for(let i in this.fileList){
  982. if(this.fileList[i].needUpload){
  983. formData.append("file", this.fileList[i].raw);
  984. }
  985. }
  986. formData.append("ContractId", this.contractForm.id);
  987. this.http.uploadFile('/contract-document/fileUpload',formData,
  988. res => {
  989. if(res.code == 'ok'){
  990. this.getContractList()
  991. }else{
  992. this.$message({
  993. message: res.msg,
  994. type: 'error'
  995. })
  996. }
  997. },err => {
  998. this.$message({
  999. message: err,
  1000. type: 'error'
  1001. })
  1002. })
  1003. },
  1004. getContractType(){
  1005. this.http.post('/contractType/getContractType',{},
  1006. res=>{
  1007. if(res.code=='ok'){
  1008. this.typeList = res.data
  1009. }else{
  1010. this.$message({
  1011. message: res.msg,
  1012. type: 'error'
  1013. })
  1014. }
  1015. },err=>{
  1016. this.$message({
  1017. message: err,
  1018. type: 'error'
  1019. })
  1020. })
  1021. },
  1022. getContractList(){
  1023. // pageIndex,pageSize,number,name,typeName,status,startDate,endDate
  1024. let parameter = {
  1025. pageIndex: this.page,
  1026. pageSize: this.size,
  1027. }
  1028. if(this.typeName){
  1029. parameter.typeName = this.typeName
  1030. }
  1031. if(this.keyword){
  1032. if(this.searchField){
  1033. parameter.number = this.keyword
  1034. }else{
  1035. parameter.name = this.keyword
  1036. }
  1037. }
  1038. if(this.status !== ''){
  1039. parameter.status = this.status
  1040. }
  1041. if(this.dateArray && this.dateArray.length == 2){
  1042. parameter.startDate = this.dateArray[0]
  1043. parameter.endDate = this.dateArray[1]
  1044. }
  1045. if(this.paymentDate && this.paymentDate.length == 2){
  1046. parameter.paymentStartDate = this.paymentDate[0]
  1047. parameter.paymentEndDate = this.paymentDate[1]
  1048. }
  1049. this.listLoading = true
  1050. this.http.post('/contract/getContractPage',parameter,
  1051. res => {
  1052. this.listLoading = false
  1053. if(res.code == 'ok'){
  1054. this.contractList = res.data.data
  1055. this.total = res.data.total
  1056. }else{
  1057. this.$message({
  1058. message: res.msg,
  1059. type: 'error'
  1060. })
  1061. }
  1062. },err => {
  1063. this.listLoading = false
  1064. this.$message({
  1065. message: err,
  1066. type: 'error'
  1067. })
  1068. })
  1069. }
  1070. },
  1071. }
  1072. </script>
  1073. <style>
  1074. .lookoverContract{
  1075. margin-top: 30px;
  1076. }
  1077. .lookoverContract .el-form-item{
  1078. width: 50%;
  1079. float: left;
  1080. }
  1081. .lookoverContract .el-form-item__label{
  1082. font-weight: 600;
  1083. }
  1084. .lookoverContract .contractFiles{
  1085. width: 100%;
  1086. }
  1087. .lookoverContract .contractFiles_title{
  1088. margin-left: 5%;
  1089. font-size: 16px;
  1090. line-height: 20px;
  1091. margin-top: 16px;
  1092. }
  1093. .contractForm{
  1094. margin-top: 30px;
  1095. }
  1096. .contractForm .el-form-item{
  1097. width: 90%;
  1098. }
  1099. .contractForm .contractFiles{
  1100. width: 100%;
  1101. }
  1102. .contractForm .contractFiles_title{
  1103. margin-left: 5%;
  1104. font-size: 16px;
  1105. line-height: 20px;
  1106. margin-top: 16px;
  1107. }
  1108. </style>