index.vue 81 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796
  1. <template>
  2. <div class="app-container">
  3. <div class="search">
  4. <el-input v-model="table.getdataListParm.parammaps.fname" placeholder="饲料名称" style="width: 130px;" class="filter-item" clearable />
  5. <el-select v-model="table.getdataListParm.parammaps.fclassid" filterable placeholder="饲料类别" class="filter-item" style="width: 150px;" clearable>
  6. <el-option v-for="item in feedTypeList" :key="item.id" :label="item.mixname" :value="item.id" />
  7. </el-select>
  8. <el-select v-model="table.getdataListParm.parammaps.source" filterable placeholder="饲料来源" class="filter-item" style="width: 120px;" clearable>
  9. <el-option v-for="item in feedSourcesList" :key="item.id" :label="item.name" :value="item.id" />
  10. </el-select>
  11. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  12. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  13. </el-select>
  14. <div ref="selectInput" class="filter-item selectInput">
  15. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  16. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  17. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  18. <ul v-if="arrowUp" class="selectUl">
  19. <li><a>允许误差数</a><el-input v-model="table.getdataListParm.parammaps.allowratio"type="text" style="width: 245px;" /></li>
  20. <li><a>跳转重量域</a><el-input v-model="table.getdataListParm.parammaps.autozone" type="text" style="width: 245px;" /></li>
  21. <li>
  22. <a>跳转延时</a>
  23. <el-select v-model="table.getdataListParm.parammaps.autosecond" filterable placeholder="跳转延时" class="filter-item" style="width: 245px;" clearable>
  24. <el-option v-for="item in jumpDelayList" :key="item.value" :label="item.label" :value="item.value" />
  25. </el-select>
  26. </li>
  27. <li>
  28. <div style="float: right;">
  29. <el-button class="downminCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  30. <el-button class="miniPrimary" @click="handleSearch">搜索</el-button>
  31. </div>
  32. </li>
  33. </ul>
  34. </div>
  35. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  36. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  37. </div>
  38. <div class="operation">
  39. <el-button v-if="isRoleEdit" style="float:left;" class="success" icon="el-icon-plus" @click="handleCreate">新增</el-button>
  40. <el-button v-if="isRoleEdit" style="float:left;" class="danger" icon="el-icon-delete" @click="handleDelete">删除</el-button>
  41. <el-button class="success" style="float:left;" icon="el-icon-receiving" @click="handleFeedBank">饲料库</el-button>
  42. <el-button v-if="isOrder && isRoleEdit" style="float:left;" icon="el-icon-sort" class="success" @click="handleChangeOrder">更改顺序</el-button>
  43. <div v-else style="float:left;margin-left: 10px;">
  44. <el-button v-if="isRoleEdit" icon="el-icon-folder-checked" class="success" @click="saveChangeOrder">保存</el-button>
  45. <el-button v-if="isRoleEdit" icon="el-icon-close" class="sortCancel" @click="cancelChangeOrder">取消</el-button>
  46. </div>
  47. <el-upload style="float: right;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImport" :on-success="handleImportSuccess">
  48. <el-button v-if="isRoleEdit" class="import" icon="el-icon-download" style="float: right;">导入</el-button>
  49. </el-upload>
  50. <el-dropdown style="float: right;margin-right: 10px;">
  51. <el-button class="export" icon="el-icon-upload2">导出</el-button>
  52. <el-dropdown-menu slot="dropdown">
  53. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  54. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  55. </el-dropdown-menu>
  56. </el-dropdown>
  57. </div>
  58. <div class="table">
  59. <u-table
  60. id="table"
  61. :key="table.tableKey"
  62. v-loading="table.listLoading"
  63. element-loading-text="给我一点时间"
  64. :data="table.list"
  65. border
  66. fit
  67. highlight-current-row
  68. style="width: 100%;"
  69. :row-style="rowStyle"
  70. :cell-style="cellStyle"
  71. class="elTable table-fixed"
  72. row-key="id"
  73. @selection-change="handleSelectionChange"
  74. >
  75. <u-table-column type="selection" align="center" width="50" fixed="left" />
  76. <u-table-column label="序号" type="index" align="center" width="50" fixed="left" />
  77. <u-table-column label="饲料名称" min-width="80px" align="center" fixed="left">
  78. <template slot-scope="scope">
  79. <span>{{ scope.row.fname }}</span>
  80. </template>
  81. </u-table-column>
  82. <u-table-column label="饲料分类" min-width="80px" align="center" fixed="left">
  83. <template slot-scope="scope">
  84. <span>{{ scope.row.fclass }}</span>
  85. </template>
  86. </u-table-column>
  87. <u-table-column label="唯一编码" min-width="80px" align="center">
  88. <template slot-scope="scope">
  89. <span>{{ scope.row.feedcode }}</span>
  90. </template>
  91. </u-table-column>
  92. <u-table-column label="饲料来源" min-width="80px" align="center">
  93. <template slot-scope="scope">
  94. <span>{{ scope.row.source }}</span>
  95. </template>
  96. </u-table-column>
  97. <u-table-column label="计划类型" min-width="90px" align="center">
  98. <template slot-scope="scope">
  99. <span>{{ scope.row.printgroup }}</span>
  100. </template>
  101. </u-table-column>
  102. <u-table-column v-if="isInforvalue" label="小料秤" min-width="90px" align="center">
  103. <template slot-scope="scope">
  104. <span>{{ scope.row.smtmrname }}</span>
  105. </template>
  106. </u-table-column>
  107. <u-table-column label="允许误差数(kg)" min-width="85px" align="center">
  108. <template slot-scope="scope">
  109. <span>{{ scope.row.allowratio }}</span>
  110. </template>
  111. </u-table-column>
  112. <u-table-column label="包装单位重量(kg)" min-width="80px" align="center">
  113. <template slot-scope="scope">
  114. <span>{{ scope.row.unitweight }}</span>
  115. </template>
  116. </u-table-column>
  117. <u-table-column label="单价" min-width="50px" align="center">
  118. <template slot-scope="scope">
  119. <span>{{ scope.row.uprice }}</span>
  120. </template>
  121. </u-table-column>
  122. <u-table-column label="跳转重量域(kg)" min-width="90px" align="center">
  123. <template slot-scope="scope">
  124. <span>{{ scope.row.autozone }}</span>
  125. </template>
  126. </u-table-column>
  127. <u-table-column label="跳转延时" min-width="80px" align="center">
  128. <template slot-scope="scope">
  129. <span>{{ scope.row.autosecondname }}</span>
  130. </template>
  131. </u-table-column>
  132. <u-table-column label="确认开始" min-width="80px" align="center">
  133. <template slot-scope="scope">
  134. <span>{{ scope.row.confirmstartname }}</span>
  135. </template>
  136. </u-table-column>
  137. <u-table-column label="继电器位置" min-width="60px" align="center">
  138. <template slot-scope="scope">
  139. <span>{{ scope.row.trgaddress }}</span>
  140. </template>
  141. </u-table-column>
  142. <u-table-column label="无上域" min-width="60px" align="center">
  143. <template slot-scope="scope">
  144. <span v-if="scope.row.jmp == 0">否</span>
  145. <span v-else>是</span>
  146. </template>
  147. </u-table-column>
  148. <u-table-column label="备用字段01" min-width="90px" align="center">
  149. <template slot-scope="scope">
  150. <span>{{ scope.row.backup1 }}</span>
  151. </template>
  152. </u-table-column>
  153. <u-table-column label="备用字段02" min-width="90px" align="center">
  154. <template slot-scope="scope">
  155. <span>{{ scope.row.backup2 }}</span>
  156. </template>
  157. </u-table-column>
  158. <u-table-column label="备用字段03" min-width="90px" align="center">
  159. <template slot-scope="scope">
  160. <span>{{ scope.row.backup3 }}</span>
  161. </template>
  162. </u-table-column>
  163. <u-table-column label="是否启用" min-width="80px" align="center">
  164. <template slot-scope="scope">
  165. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  166. </template>
  167. </u-table-column>
  168. <u-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width" fixed="right">
  169. <template slot-scope="{row}">
  170. <a class="correcting" @click="handleNutritive (row)">营养价值</a>
  171. <span class="centerSpan">|</span>
  172. <a v-if="isRoleEdit" class="correcting" @click="handleRelation(row)">关联</a>
  173. <span v-if="isRoleEdit" class="centerSpan">|</span>
  174. <el-button v-if="isRoleEdit" icon="el-icon-edit-outline" class="miniSuccess" @click="handleUpdate(row)" />
  175. <span v-if="isRoleEdit" class="centerSpan">|</span>
  176. <el-button v-if="isRoleEdit" icon="el-icon-delete" class="miniDanger" @click="handleRowDelete(row)" />
  177. </template>
  178. </u-table-column>
  179. </u-table>
  180. <!-- <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" /> -->
  181. <span v-if="table.listLoading == false" style="margin-right: 30px;margin-top: 10px;font-size: 14px;">共{{ table.total }}条</span>
  182. </div>
  183. <!-- 新增/编辑 -->
  184. <el-dialog :fullscreen="dialogFull" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="90%">
  185. <template slot="title">
  186. <div class="avue-crud__dialog__header">
  187. <span class="el-dialog__title">
  188. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  189. {{ textMap[create.dialogStatus] }}
  190. </span>
  191. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  192. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  193. <svg-icon v-else icon-class="fullscreen" />
  194. </div>
  195. </div>
  196. </template>
  197. <div class="app-add">
  198. <el-form ref="temp" :rules="create.rules" :model="create.temp" label-position="right" label-width="155px" style="width: 100%;margin:0 auto 50px">
  199. <el-row>
  200. <el-col :span="24">
  201. <h3 style="width: 160px;text-align: right;">基础信息</h3>
  202. </el-col>
  203. </el-row>
  204. <el-row>
  205. <el-col :span="6">
  206. <el-form-item label="饲料名称:" prop="fname">
  207. <el-input ref="fname" v-model="create.temp.fname" class="filter-item" placeholder="请输入饲料名称" type="textarea" :autosize="{ minRows:1}" maxlength="32" />
  208. </el-form-item>
  209. </el-col>
  210. <el-col :span="6">
  211. <el-form-item label="饲料类别:" prop="fclassid">
  212. <el-select v-model="create.temp.fclassid" filterable placeholder="饲料类别" class="filter-item" style="width: 100%;" @change="changeFeedList">
  213. <el-option v-for="item in feedTypeList" :key="item.id" :label="item.mixname" :value="item.id" />
  214. </el-select>
  215. </el-form-item>
  216. </el-col>
  217. <el-col :span="6">
  218. <el-form-item label="唯一编码:" prop="feedcode">
  219. <el-input ref="feedcode" v-model="create.temp.feedcode" class="filter-item" placeholder="请输入唯一编码" type="text" />
  220. </el-form-item>
  221. </el-col>
  222. <el-col :span="6">
  223. <el-form-item label="饲料来源:" prop="source">
  224. <el-input ref="source" v-model="create.temp.source" class="filter-item" disabled placeholder="用户自定义" type="text" />
  225. </el-form-item>
  226. </el-col>
  227. </el-row>
  228. <el-row>
  229. <el-col :span="6">
  230. <el-form-item label="计划类型:" prop="printgroupid">
  231. <el-select v-model="create.temp.printgroupid" filterable placeholder="计划类型" class="filter-item" style="width: 100%;" @change="changePlanList">
  232. <el-option v-for="item in planTypeList" :key="item.value" :label="item.label" :value="item.value" />
  233. </el-select>
  234. </el-form-item>
  235. </el-col>
  236. <el-col :span="6">
  237. <el-form-item label="包装单位重量(kg):" prop="unitweight">
  238. <el-input ref="unitweight" v-model="create.temp.unitweight" class="filter-item" placeholder="正整数" type="number" style="width: 100%;" />
  239. </el-form-item>
  240. </el-col>
  241. <el-col :span="6">
  242. <el-form-item label="单价:" prop="uprice">
  243. <el-input ref="uprice" v-model="create.temp.uprice" class="filter-item" placeholder="最多俩位小数" type="number" step="0.01" style="width: 100%;" />
  244. </el-form-item>
  245. </el-col>
  246. </el-row>
  247. <el-row>
  248. <el-col :span="24">
  249. <h3 style="width: 160px;text-align: right;">搅拌参数</h3>
  250. </el-col>
  251. </el-row>
  252. <el-row>
  253. <el-col :span="6">
  254. <el-form-item label="允许误差数(kg):" prop="allowratio">
  255. <el-input ref="allowratio" v-model="create.temp.allowratio" class="filter-item" placeholder="正整数" type="text" />
  256. </el-form-item>
  257. </el-col>
  258. <el-col :span="6">
  259. <el-form-item label="跳转重量域(kg):" prop="autozone">
  260. <el-input ref="autozone" v-model="create.temp.autozone" :disabled="create.temp.autosecond=='0'" class="filter-item" placeholder="0-50之间的整数" type="text" />
  261. </el-form-item>
  262. </el-col>
  263. <el-col :span="6">
  264. <el-form-item label="跳转延时:" prop="autosecond">
  265. <el-select v-model="create.temp.autosecond" filterable placeholder="跳转延时" class="filter-item" style="width: 100%;" @change="changeAutosecond">
  266. <el-option v-for="item in jumpDelayList" :key="item.value" :label="item.label" :value="item.value" />
  267. </el-select>
  268. </el-form-item>
  269. </el-col>
  270. <el-col :span="6">
  271. <el-form-item label="确认开始:" prop="confirmstart">
  272. <el-select v-model="create.temp.confirmstart" filterabler placeholde="确认开始" class="filter-item" style="width: 100%;" @change="changeConfirmstart">
  273. <el-option v-for="item in confirmStartList" :key="item.id" :label="item.name" :value="item.id" />
  274. </el-select>
  275. </el-form-item>
  276. </el-col>
  277. </el-row>
  278. <el-row>
  279. <el-col :span="6">
  280. <el-form-item label="是否启用:" prop="enable">
  281. <el-select v-model="create.temp.enable" filterable placeholder="是否启用" class="filter-item" style="width: 100%;">
  282. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  283. </el-select>
  284. </el-form-item>
  285. </el-col>
  286. <el-col :span="6">
  287. <el-form-item label="继电器位置:" prop="trgaddress">
  288. <el-input ref="trgaddress" v-model="create.temp.trgaddress" class="filter-item" placeholder="继电器位置" type="number" />
  289. </el-form-item>
  290. </el-col>
  291. <el-col v-if="isInforvalue" :span="6">
  292. <el-form-item label="小料秤:" prop="smtmrid">
  293. <el-select v-model="create.temp.smtmrid" filterable placeholder="小料秤" clearable class="filter-item" style="width: 100%;" @change="changeSmallMaterial">
  294. <el-option v-for="item in smallMaterialList" :key="item.id" :label="item.tname" :value="item.id" />
  295. </el-select>
  296. </el-form-item>
  297. </el-col>
  298. <el-col :span="6">
  299. <el-form-item label="无上域:" prop="jmp">
  300. <el-select v-model="create.temp.jmp" placeholder="无上域" class="filter-item" style="width: 100%;" @change="changeSmallMaterial">
  301. <el-option v-for="item in jmpList" :key="item.id" :label="item.name" :value="item.id" />
  302. </el-select>
  303. </el-form-item>
  304. </el-col>
  305. </el-row>
  306. <el-row>
  307. <h3 style="width: 160px;text-align: right;">备用字段</h3>
  308. </el-row>
  309. <el-row>
  310. <el-col :span="6">
  311. <el-form-item label="备用字段01:" prop="backup1">
  312. <el-input ref="backup1" v-model="create.temp.backup1" class="filter-item" placeholder="备用字段01" type="text" />
  313. </el-form-item>
  314. </el-col>
  315. <el-col :span="6">
  316. <el-form-item label="备用字段02:" prop="backup2">
  317. <el-input ref="backup2" v-model="create.temp.backup2" class="filter-item" placeholder="备用字段02" type="text" />
  318. </el-form-item>
  319. </el-col>
  320. <el-col :span="6">
  321. <el-form-item label="备用字段03:" prop="backup3">
  322. <el-input ref="backup3" v-model="create.temp.backup3" class="filter-item" placeholder="备用字段03" type="text" />
  323. </el-form-item>
  324. </el-col>
  325. </el-row>
  326. </el-form>
  327. <div slot="footer" class="dialog-footer">
  328. <el-button class="cancelClose" @click="create.dialogFormVisible = false;getList()">关闭</el-button>
  329. <el-button v-if="create.dialogStatus==='create' || create.dialogStatus==='update'" class="save" :disabled="isokDisable" @click="create.dialogStatus==='create'?createData():updateData()">确认</el-button>
  330. </div>
  331. </div>
  332. </el-dialog>
  333. <!-- 饲料库 -->
  334. <el-dialog :fullscreen="dialogFull" :visible.sync="feedBank.dialogFormVisible" :close-on-click-modal="false" width="90%">
  335. <template slot="title">
  336. <div class="avue-crud__dialog__header">
  337. <span class="el-dialog__title">
  338. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  339. {{ textMap[feedBank.dialogStatus] }}
  340. </span>
  341. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  342. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  343. <svg-icon v-else icon-class="fullscreen" />
  344. </div>
  345. </div>
  346. </template>
  347. <div class="app-add">
  348. <div class="search">
  349. <el-input v-model="feedBank.getdataListParm.parammaps.fname" placeholder="饲料名称" style="width: 130px;" class="filter-item" clearable />
  350. <el-select v-model="feedBank.getdataListParm.parammaps.statue" filterabler placeholder="关联状态" class="filter-item" style="width: 120px;" clearable>
  351. <el-option v-for="item in associationStatusList" :key="item.id" :label="item.name" :value="item.id" />
  352. </el-select>
  353. <el-button class="successBorder" @click="handleFeedBankSearch">查询</el-button>
  354. <el-button class="successBorder" @click="handleFeedBankRefresh">重置</el-button>
  355. </div>
  356. <div class="table">
  357. <el-table
  358. :key="feedBank.tableKey"
  359. v-loading="feedBank.listLoading"
  360. element-loading-text="给我一点时间"
  361. :data="feedBank.list"
  362. border
  363. fit
  364. highlight-current-row
  365. style="width: 100%;margin: 0 auto 50px;"
  366. :row-style="rowStyle"
  367. :cell-style="cellStyle"
  368. class="elTable table-fixed"
  369. >
  370. <el-table-column label="序号" align="center" type="index" width="50px" />
  371. <el-table-column label="来源" min-width="50" align="center">
  372. <template slot-scope="scope">
  373. <span>{{ scope.row.sources }}</span>
  374. </template>
  375. </el-table-column>
  376. <el-table-column label="中国饲料号" min-width="70px" align="center">
  377. <template slot-scope="scope">
  378. <span>{{ scope.row.feedcode }}</span>
  379. </template>
  380. </el-table-column>
  381. <el-table-column label="饲料名称" min-width="80px" align="center">
  382. <template slot-scope="scope">
  383. <span>{{ scope.row.fname }}</span>
  384. </template>
  385. </el-table-column>
  386. <el-table-column label="价格" min-width="50px" align="center">
  387. <template slot-scope="scope">
  388. <span>{{ scope.row.price }}</span>
  389. </template>
  390. </el-table-column>
  391. <el-table-column label="样品说明" min-width="50px" align="center">
  392. <template slot-scope="scope">
  393. <span>{{ scope.row.remark }}</span>
  394. </template>
  395. </el-table-column>
  396. <el-table-column label="干物质(DM%)" min-width="65px" align="center">
  397. <template slot-scope="scope">
  398. <span>{{ scope.row.dry }}</span>
  399. </template>
  400. </el-table-column>
  401. <el-table-column label="淀粉(%DM)" min-width="59px" align="center">
  402. <template slot-scope="scope">
  403. <span>{{ scope.row.starch }}</span>
  404. </template>
  405. </el-table-column>
  406. <el-table-column label="粗蛋白(CP%DM)" min-width="70px" align="center">
  407. <template slot-scope="scope">
  408. <span>{{ scope.row.cp }}</span>
  409. </template>
  410. </el-table-column>
  411. <el-table-column label="钙(Ca%DM)" min-width="85px" align="center">
  412. <template slot-scope="scope">
  413. <span>{{ scope.row.ca }}</span>
  414. </template>
  415. </el-table-column>
  416. <el-table-column label="磷(P%DM)" min-width="85px" align="center">
  417. <template slot-scope="scope">
  418. <span>{{ scope.row.p }}</span>
  419. </template>
  420. </el-table-column>
  421. <el-table-column label="产奶净能(%DM)" min-width="75px" align="center">
  422. <template slot-scope="scope">
  423. <span>{{ scope.row.n }}</span>
  424. </template>
  425. </el-table-column>
  426. <el-table-column label="脂肪(%DM)" min-width="59px" align="center">
  427. <template slot-scope="scope">
  428. <span>{{ scope.row.fat }}</span>
  429. </template>
  430. </el-table-column>
  431. <el-table-column label="ADF(%DM)" min-width="60px" align="center">
  432. <template slot-scope="scope">
  433. <span>{{ scope.row.adf }}</span>
  434. </template>
  435. </el-table-column>
  436. <el-table-column label="NDF(%DM)" min-width="60px" align="center">
  437. <template slot-scope="scope">
  438. <span>{{ scope.row.ndf }}</span>
  439. </template>
  440. </el-table-column>
  441. <el-table-column label="NDIP%" min-width="70px" align="center">
  442. <template slot-scope="scope">
  443. <span>{{ scope.row.ndip }}</span>
  444. </template>
  445. </el-table-column>
  446. <el-table-column label="粗灰分(Ash%)" min-width="65px" align="center">
  447. <template slot-scope="scope">
  448. <span>{{ scope.row.ash }}</span>
  449. </template>
  450. </el-table-column>
  451. <el-table-column label="粗料" min-width="50px" align="center">
  452. <template slot-scope="scope">
  453. <span>{{ scope.row.iscu }}</span>
  454. </template>
  455. </el-table-column>
  456. <el-table-column label="关联状态" min-width="50px" align="center">
  457. <template slot-scope="scope">
  458. <span v-if="scope.row.statue==0">否</span>
  459. <span v-if="scope.row.statue==1">是</span>
  460. </template>
  461. </el-table-column>
  462. </el-table>
  463. </div>
  464. <div slot="footer" class="dialog-footer">
  465. <el-button class="cancelClose cancelClose1" @click="feedBank.dialogFormVisible = false; ">关闭</el-button>
  466. </div>
  467. </div>
  468. </el-dialog>
  469. <!-- 关联 -->
  470. <el-dialog :fullscreen="dialogFull" :visible.sync="relation.dialogFormVisible" :close-on-click-modal="false" width="90%">
  471. <template slot="title">
  472. <div class="avue-crud__dialog__header">
  473. <span class="el-dialog__title">
  474. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  475. {{ textMap[relation.dialogStatus] }}
  476. </span>
  477. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  478. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  479. <svg-icon v-else icon-class="fullscreen" />
  480. </div>
  481. </div>
  482. </template>
  483. <div class="app-add">
  484. <div class="search">
  485. <el-input v-model="relation.getdataListParm.parammaps.fname" placeholder="饲料名称" style="width: 130px;" class="filter-item" clearable />
  486. <el-button class="successBorder" @click="handleRelationSearch">查询</el-button>
  487. </div>
  488. <div class="table">
  489. <el-table
  490. :key="relation.tableKey"
  491. v-loading="relation.listLoading"
  492. element-loading-text="给我一点时间"
  493. :data="relation.list"
  494. border
  495. fit
  496. highlight-current-row
  497. style="width: 100%;margin: 0 auto 50px;"
  498. :row-style="rowStyle"
  499. :cell-style="cellStyle"
  500. class="elTable table-fixed"
  501. >
  502. <el-table-column label="序号" align="center" type="index" width="50px" />
  503. <el-table-column label="来源" min-width="50" align="center">
  504. <template slot-scope="scope">
  505. <span>{{ scope.row.sources }}</span>
  506. </template>
  507. </el-table-column>
  508. <el-table-column label="中国饲料号" min-width="80px" align="center">
  509. <template slot-scope="scope">
  510. <span>{{ scope.row.feedcode }}</span>
  511. </template>
  512. </el-table-column>
  513. <el-table-column label="饲料名称" min-width="80px" align="center">
  514. <template slot-scope="scope">
  515. <span>{{ scope.row.fname }}</span>
  516. </template>
  517. </el-table-column>
  518. <el-table-column label="价格" min-width="50px" align="center">
  519. <template slot-scope="scope">
  520. <span>{{ scope.row.price }}</span>
  521. </template>
  522. </el-table-column>
  523. <el-table-column label="样品说明" min-width="50px" align="center">
  524. <template slot-scope="scope">
  525. <span>{{ scope.row.remark }}</span>
  526. </template>
  527. </el-table-column>
  528. <el-table-column label="干物质(DM%)" min-width="65px" align="center">
  529. <template slot-scope="scope">
  530. <span>{{ scope.row.dry }}</span>
  531. </template>
  532. </el-table-column>
  533. <el-table-column label="淀粉(%DM)" min-width="59px" align="center">
  534. <template slot-scope="scope">
  535. <span>{{ scope.row.starch }}</span>
  536. </template>
  537. </el-table-column>
  538. <el-table-column label="粗蛋白(CP%DM)" min-width="75px" align="center">
  539. <template slot-scope="scope">
  540. <span>{{ scope.row.cp }}</span>
  541. </template>
  542. </el-table-column>
  543. <el-table-column label="钙(Ca%DM)" min-width="83px" align="center">
  544. <template slot-scope="scope">
  545. <span>{{ scope.row.ca }}</span>
  546. </template>
  547. </el-table-column>
  548. <el-table-column label="磷(P%DM)" min-width="80px" align="center">
  549. <template slot-scope="scope">
  550. <span>{{ scope.row.p }}</span>
  551. </template>
  552. </el-table-column>
  553. <el-table-column label="产奶净能(%DM)" min-width="75px" align="center">
  554. <template slot-scope="scope">
  555. <span>{{ scope.row.n }}</span>
  556. </template>
  557. </el-table-column>
  558. <el-table-column label="脂肪(%DM)" min-width="59px" align="center">
  559. <template slot-scope="scope">
  560. <span>{{ scope.row.fat }}</span>
  561. </template>
  562. </el-table-column>
  563. <el-table-column label="ADF(%DM)" min-width="60px" align="center">
  564. <template slot-scope="scope">
  565. <span>{{ scope.row.adf }}</span>
  566. </template>
  567. </el-table-column>
  568. <el-table-column label="NDF(%DM)" min-width="60px" align="center">
  569. <template slot-scope="scope">
  570. <span>{{ scope.row.ndf }}</span>
  571. </template>
  572. </el-table-column>
  573. <el-table-column label="NDIP%" min-width="70px" align="center">
  574. <template slot-scope="scope">
  575. <span>{{ scope.row.ndip }}</span>
  576. </template>
  577. </el-table-column>
  578. <el-table-column label="粗灰分(Ash%)" min-width="65px" align="center">
  579. <template slot-scope="scope">
  580. <span>{{ scope.row.ash }}</span>
  581. </template>
  582. </el-table-column>
  583. <el-table-column label="粗料" min-width="50px" align="center">
  584. <template slot-scope="scope">
  585. <span>{{ scope.row.iscu }}</span>
  586. </template>
  587. </el-table-column>
  588. <el-table-column label="操作" min-width="50px" align="center" class-name="small-padding fixed-width" fixed="right">
  589. <template slot-scope="{row}">
  590. <a v-if="row.statueRelation == '1'" class="correcting" :disabled="isokDisable" @click="disassociateData(row)">取消关联</a>
  591. <a v-if="row.statueRelation == '0'" class="correcting" :disabled="isokDisable" @click="relationData(row)">关联</a>
  592. </template>
  593. </el-table-column>
  594. </el-table>
  595. </div>
  596. <div slot="footer" class="dialog-footer">
  597. <el-button class="cancelClose cancelClose1" @click="relation.dialogFormVisible = false;getList() ">关闭</el-button>
  598. </div>
  599. </div>
  600. </el-dialog>
  601. <!-- 营养价值 -->
  602. <el-dialog :fullscreen="dialogFull" :visible.sync="nutritive.dialogFormVisible" :close-on-click-modal="false" width="90%">
  603. <template slot="title">
  604. <div class="avue-crud__dialog__header">
  605. <span class="el-dialog__title">
  606. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  607. {{ textMap[nutritive.dialogStatus] }}
  608. </span>
  609. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  610. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  611. <svg-icon v-else icon-class="fullscreen" />
  612. </div>
  613. </div>
  614. </template>
  615. <div class="app-add">
  616. <el-form ref="temp" :rules="nutritive.rules" :model="nutritive.temp" label-position="right" label-width="160px" style="width: 100%;margin:0 auto 50px">
  617. <el-row>
  618. <el-col :span="6">
  619. <el-form-item label="干物质(DM%):" prop="dry">
  620. <el-input ref="dry" v-model="nutritive.temp.dry" :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入干物质" type="number" step="0.01" />
  621. </el-form-item>
  622. </el-col>
  623. <el-col :span="6">
  624. <el-form-item label="淀粉(%DM):" prop="starch">
  625. <el-input ref="starch" v-model="nutritive.temp.starch" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入淀粉" type="number" step="0.01" />
  626. </el-form-item>
  627. </el-col>
  628. <el-col :span="6">
  629. <el-form-item label="粗蛋白(CP%DM):" prop="cp">
  630. <el-input ref="cp" v-model="nutritive.temp.cp" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入粗蛋白" type="number" step="0.01" />
  631. </el-form-item>
  632. </el-col>
  633. <el-col :span="6">
  634. <el-form-item label="钙(Ca%DM):" prop="ca">
  635. <el-input ref="ca" v-model="nutritive.temp.ca" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入钙" type="number" step="0.01" />
  636. </el-form-item>
  637. </el-col>
  638. </el-row>
  639. <el-row>
  640. <el-col :span="6">
  641. <el-form-item label="磷(P%DM):" prop="p">
  642. <el-input ref="p" v-model="nutritive.temp.p" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入磷" type="number" step="0.01" />
  643. </el-form-item>
  644. </el-col>
  645. <el-col :span="6">
  646. <el-form-item label="产奶净能(%DM):" prop="n">
  647. <el-input ref="n" v-model="nutritive.temp.n" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入产奶净能" type="number" step="0.01" />
  648. </el-form-item>
  649. </el-col>
  650. <el-col :span="6">
  651. <el-form-item label="脂肪(%DM):" prop="fat">
  652. <el-input ref="fat" v-model="nutritive.temp.fat" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入脂肪" type="number" step="0.01" />
  653. </el-form-item>
  654. </el-col>
  655. <el-col :span="6">
  656. <el-form-item label="ADF(%DM):" prop="adf">
  657. <el-input ref="adf" v-model="nutritive.temp.adf" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入ADF" type="number" step="0.01" />
  658. </el-form-item>
  659. </el-col>
  660. </el-row>
  661. <el-row>
  662. <el-col :span="6">
  663. <el-form-item label="NDF(%DM):" prop="ndf">
  664. <el-input ref="ndf" v-model="nutritive.temp.ndf" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入NDF" type="number" step="0.01" />
  665. </el-form-item>
  666. </el-col>
  667. <el-col :span="6">
  668. <el-form-item label="NDIP(%):" prop="ndip">
  669. <el-input ref="ndip" v-model="nutritive.temp.ndip" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入NDIP" type="number" step="0.01" />
  670. </el-form-item>
  671. </el-col>
  672. <el-col :span="6">
  673. <el-form-item label="粗灰分(Ash%):" prop="ash">
  674. <el-input ref="ash" v-model="nutritive.temp.ash" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入粗灰分" type="number" min="0.00" step="0.01" />
  675. </el-form-item>
  676. </el-col>
  677. </el-row>
  678. </el-form>
  679. <div slot="footer" class="dialog-footer">
  680. <el-button class="cancelClose" @click="nutritive.dialogFormVisible = false;getList()">关闭</el-button>
  681. <el-button v-if="nutritive.dialogStatus==='nutritive' && isRoleEdit" class="save" :disabled="isokDisable" @click="nutritiveData()">确认</el-button>
  682. </div>
  683. </div>
  684. </el-dialog>
  685. </div>
  686. </template>
  687. <script>
  688. import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, GetDataByNames, checkButtons } from '@/api/common'
  689. import Cookies from 'js-cookie'
  690. import Sortable from 'sortablejs'
  691. import Pagination from '@/components/Pagination'
  692. import axios from 'axios'
  693. import { getToken } from '@/utils/auth'
  694. import { parseTime, json2excel, handleTableSpan, handleObjectSpanMethod } from '@/utils/index.js'
  695. import { MessageBox } from 'element-ui'
  696. export default {
  697. name: 'FeedTable',
  698. components: { Pagination },
  699. directives: {
  700. limit: {
  701. // 指令的定义
  702. update: function(el) {
  703. el.onkeypress = function(e) {
  704. var code = e.charCode
  705. if (code != 0) {
  706. if (!String.fromCharCode(code).match(/[0-9\.]/)) {
  707. return false
  708. }
  709. }
  710. }
  711. el.addEventListener('textInput', function(e) {
  712. e.target.value = e.target.value.replace(/[^0-9\.]/g, '')
  713. })
  714. el.onkeyup = function(e) {
  715. e.target.value = e.target.value.replace(/[^0-9\.]/g, '')
  716. }
  717. }
  718. }
  719. },
  720. data() {
  721. return {
  722. dialogFull: false,
  723. isInforvalue: false,
  724. isRoleEdit: [],
  725. download: {
  726. getdataListParm: {
  727. name: 'getFeedList',
  728. page: 1,
  729. offset: 1,
  730. pagecount: 0,
  731. returntype: 'Map',
  732. parammaps: {
  733. pastureid: Cookies.get('pastureid'),
  734. fname: '',
  735. fclassid: '',
  736. source: '',
  737. autozone: '',
  738. autosecond: '',
  739. allowratio: '',
  740. printgroup: '',
  741. enable: ''
  742. }
  743. },
  744. list: []
  745. },
  746. requestParams: [
  747. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['跳转延时'] },
  748. { name: 'getFeedclassByBig', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
  749. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['计划类型'] },
  750. { name: 'getTMRListEnableTypeFeed', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid'), eqtype: '4' }}
  751. ],
  752. requestParams2: {
  753. name: 'getSysoptEnable', offset: 0, parammaps: { pastureid: Cookies.get('pastureid'), inforname: 'isSmallMaterial' }
  754. },
  755. enableList: [{ id: '1', name: '是' }, { id: '0', name: '否' }], // 是否启用
  756. feedSourcesList: [{ id: '0', name: '系统内置' }, { id: '1', name: '用户自定义' }], // 饲料来源
  757. confirmStartList: [{ id: '0', name: '禁用' }, { id: '1', name: '启用' }], // 确认开始
  758. associationStatusList: [{ id: '1', name: '是' }, { id: '0', name: '否' }], // 关联状态
  759. jumpDelayList: [], // 跳转延时
  760. feedTypeList: [], // 饲料分类
  761. planTypeList: [], // 计划类型
  762. smallMaterialList: [], // 小料秤
  763. jmpList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 无上域
  764. table: {
  765. tableKey: 0,
  766. list: [],
  767. total: 0,
  768. listLoading: true,
  769. getdataListParm: {
  770. name: 'getFeedList',
  771. page: 1,
  772. offset: 1,
  773. pagecount: '',
  774. returntype: 'Map',
  775. parammaps: {
  776. pastureid: Cookies.get('pastureid'),
  777. fname: '',
  778. fclassid: '',
  779. source: '',
  780. autozone: '',
  781. autosecond: '',
  782. allowratio: '',
  783. printgroup: '',
  784. enable: ''
  785. }
  786. }
  787. },
  788. // 多项搜索显示隐藏
  789. arrowDown: true,
  790. arrowUp: false,
  791. // 新增/编辑
  792. create: {
  793. dialogFormVisible: false,
  794. dialogStatus: '',
  795. temp: { pastureid: Cookies.get('pastureid'), fname: '', fclassid: '', fclass: '', feedcode: '', source: '用户自定义', printgroupid: '1', printgroup: '无', unitweight: '', uprice: '', allowratio: '', autozone: '', autosecond: '0', autosecondname: '禁用', confirmstart: '0', confirmstartname: '禁用', enable: '1', trgaddress: '', backup1: '', backup2: '', backup3: '' },
  796. rules: {
  797. printgroupid :[{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  798. fname: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  799. fclassid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  800. feedcode: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  801. }
  802. },
  803. // 饲料库
  804. feedBank: {
  805. dialogFormVisible: false,
  806. dialogStatus: '',
  807. temp: {},
  808. rules: {},
  809. tableKey: 0,
  810. list: [],
  811. total: 0,
  812. listLoading: true,
  813. getdataListParm: {
  814. name: 'getFeednurList',
  815. page: 1,
  816. offset: 1,
  817. returntype: 'Map',
  818. parammaps: {
  819. pastureid: Cookies.get('pastureid'),
  820. fname: '',
  821. statue: ''
  822. }
  823. }
  824. },
  825. // 关联
  826. relation: {
  827. dialogFormVisible: false,
  828. dialogStatus: '',
  829. temp: {},
  830. rules: {},
  831. tableKey: 0,
  832. list: [],
  833. total: 0,
  834. listLoading: true,
  835. getdataListParm: {
  836. name: 'getFeednurRelation',
  837. page: 1,
  838. offset: 1,
  839. returntype: 'Map',
  840. parammaps: {
  841. pastureid: Cookies.get('pastureid'),
  842. fname: ''
  843. }
  844. }
  845. },
  846. // 营养价值
  847. nutritive: {
  848. dialogFormVisible: false,
  849. dialogStatus: '',
  850. temp: {},
  851. rules: {}
  852. },
  853. textMap: {
  854. create: '新增',
  855. update: '编辑',
  856. feedBank: '饲料库',
  857. relation: '关联',
  858. nutritive: '营养价值'
  859. },
  860. isokDisable: false,
  861. selectList: [],
  862. requestParam: {},
  863. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  864. cellStyle: { padding: 0 + 'px' },
  865. dropState: false,
  866. isOrder: true
  867. }
  868. },
  869. computed: {
  870. // 设置请求头
  871. headers() {
  872. return {
  873. token: getToken()
  874. }
  875. },
  876. uploadData() {
  877. return {
  878. name: 'fname,fclass,feedcode,source,printgroup,allowratio,unitweight,uprice,autozone,autosecondnam,onfirmstartname,trgaddress,jmp,backup1,backup2,backup3',
  879. importParams: '饲料名称,饲料分类,唯一编码,饲料来源,计划类型,允许误差数(kg),包装单位重量(kg),单价,跳转重量域(kg),跳转延时,确认开始,继电器位置,无上域,备用字段01,备用字段02,备用字段03',
  880. sheetname: 'Sheet1',
  881. // 登录牧场
  882. pastureid: Cookies.get('pastureid'),
  883. // 日期参数
  884. dateParams: '',
  885. // 必填参数
  886. requiredParams: '饲料名称,饲料分类',
  887. // 为数值的参数
  888. numParams: ''
  889. }
  890. },
  891. // 设置上传地址
  892. uploadExcelUrl() {
  893. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  894. }
  895. },
  896. mounted() {
  897. document.addEventListener('click', (e) => {
  898. if (this.$refs.selectInput !== undefined) {
  899. if (!this.$refs.selectInput.contains(e.target)) {
  900. this.arrowDown = true
  901. this.arrowUp = false
  902. } else {
  903. this.arrowDown = false
  904. this.arrowUp = true
  905. }
  906. }
  907. })
  908. },
  909. created() {
  910. this.getList()
  911. this.getDownList()
  912. this.getButtons()
  913. this.getInforvalueList()
  914. },
  915. methods: {
  916. beforeImport(file) {
  917. const isLt2M = file.size / 1024 / 1024 < 2
  918. if (!isLt2M) {
  919. this.$message.error('上传文件大小不能超过 2MB!')
  920. }
  921. return isLt2M
  922. },
  923. handleImportSuccess(res, file) {
  924. this.getList()
  925. if (res.msg === 'ok') {
  926. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  927. if (res.data.err_count > 0) {
  928. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  929. import('@/vendor/Export2Excel').then(excel => {
  930. const list1 = res.data.result
  931. const tHeader = [
  932. '饲料名称', '饲料分类', '唯一编码', '计划类型', '允许误差数(kg)', '包装单位重量(kg)', '单价', '跳转重量域(kg)', '跳转延时', '确认开始', '继电器位置', '无上域', '备用字段01', '备用字段02', '备用字段03', '错误信息'
  933. ]
  934. const filterVal = [
  935. '饲料名称', '饲料分类', '唯一编码', '计划类型', '允许误差数(kg)', '包装单位重量(kg)', '单价', '跳转重量域(kg)', '跳转延时', '确认开始', '继电器位置', '无上域', '备用字段01', '备用字段02', '备用字段03', 'error_msg'
  936. ]
  937. const data1 = this.formatJson(filterVal, list1)
  938. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '饲料表导入报错信息', autoWidth: true, bookType: 'xlsx' })
  939. })
  940. }
  941. } else {
  942. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  943. }
  944. },
  945. formatJson(filterVal, jsonData) {
  946. return jsonData.map(v =>
  947. filterVal.map(j => {
  948. if (j === 'timestamp') {
  949. return parseTime(v[j])
  950. } else {
  951. return v[j]
  952. }
  953. })
  954. )
  955. },
  956. handleExport(item) {
  957. if (item == 1) {
  958. console.log('点击了导出模板')
  959. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  960. console.log('点击了导出模板',this.download.getdataListParm)
  961. GetDataByName(this.download.getdataListParm).then(response => {
  962. if (response.data.list !== null) {
  963. this.download.list = response.data.list
  964. } else {
  965. this.download.list = []
  966. }
  967. console.log(this.download.list)
  968. var downloadList = [
  969. { 'obj1': '1、文件类型为xlsx类型,对应表格文件名格式为:文件名称.xlsx;' },
  970. { 'obj1': '2、底部工作表名称不可更改,默认为:Sheet1;' },
  971. // { 'obj1': '3、栏舍名称,实际牛头数,系数(%),系数头数,配方模板,补料配方字体为必填;' },
  972. // { 'obj1': '4、第一列栏舍名称默认为系统中栏舍,不可修改;' },
  973. // { 'obj1': '5、实际牛头数为正整数,系数为正数,至多保留俩位小数;' },
  974. // { 'obj1': '6、配方模板名称必须与系统中配方计划—配方模板中的饲喂配方匹配;若补料配方开启,需与配方模板中的补料配方匹配;' },
  975. // { 'obj1': '7、数据最多可导入200条,超过200条请分多个文件导入。' }
  976. ]
  977. var excelDatas = [
  978. {
  979. tHeader: [
  980. '饲料名称', '饲料分类', '唯一编码', '饲料来源', '计划类型', '允许误差数(kg)', '包装单位重量(kg)', '单价', '跳转重量域(kg)', '跳转延时', '确认开始', '继电器位置', '无上域', '备用字段01', '备用字段02', '备用字段03'
  981. ],
  982. filterVal: ['', '', '', '', '','', '', '', '', '', '', '', '', '', '', ''],
  983. tableDatas: this.download.list,
  984. sheetName: 'Sheet1'
  985. }, {
  986. tHeader: ['填写规范:'],
  987. filterVal: ['obj1'],
  988. tableDatas: downloadList,
  989. sheetName: 'Sheet2'
  990. }
  991. ]
  992. json2excel(excelDatas, '饲料表导入模板', true, 'xlsx')
  993. })
  994. // console.log('点击了导出模板')
  995. // const requestParam = this.requestParam
  996. // const url = process.env.VUE_APP_BASE_API + 'file/导入导出模板/库存管理/饲料表导入模板.xlsx' // 请求下载文件的地址
  997. // console.log(url)
  998. // axios({
  999. // method: 'GET',
  1000. // url: url,
  1001. // data: requestParam,
  1002. // headers: { token: getToken(), optname: 'insertcustomdoc' },
  1003. // responseType: 'blob'
  1004. // }).then(res => {
  1005. // if (!res) return
  1006. // this.percentage = 99
  1007. // setTimeout(() => {
  1008. // this.isPercentage = false
  1009. // }, 2000)
  1010. // const blob = new Blob([res.data], {
  1011. // type: 'application/octet-stream;charset=utf-8'
  1012. // })
  1013. // const url = window.URL.createObjectURL(blob)
  1014. // const aLink = document.createElement('a')
  1015. // aLink.style.display = 'none'
  1016. // aLink.href = url
  1017. // const docname = '饲料表导入模板.xlsx'
  1018. // aLink.setAttribute('download', docname) // 下载的文件
  1019. // document.body.appendChild(aLink)
  1020. // aLink.click()
  1021. // document.body.removeChild(aLink)
  1022. // window.URL.revokeObjectURL(url)
  1023. // })
  1024. } else {
  1025. console.log('点击了导出数据')
  1026. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  1027. GetDataByName(this.download.getdataListParm).then(response => {
  1028. if (response.data.list !== null) {
  1029. this.download.list = response.data.list
  1030. } else {
  1031. this.download.list = []
  1032. }
  1033. var excelDatas = [
  1034. {
  1035. tHeader: [
  1036. '饲料名称', '饲料分类', '唯一编码', '饲料来源', '计划类型', '允许误差数(kg)', '包装单位重量(kg)', '单价', '跳转重量域(kg)', '跳转延时', '确认开始', '继电器位置', '无上域', '备用字段01', '备用字段02', '备用字段03'
  1037. ],
  1038. filterVal: ['fname', 'fclass', 'feedcode', 'source', 'printgroup', 'allowratio', 'unitweight', 'uprice', 'autozone', 'autosecondnam', 'onfirmstartname', 'trgaddress', 'jmp', 'backup1', 'backup2', 'backup3'],
  1039. tableDatas: this.download.list,
  1040. sheetName: 'Sheet1'
  1041. }
  1042. ]
  1043. json2excel(excelDatas, '饲料表', true, 'xlsx')
  1044. })
  1045. }
  1046. },
  1047. getButtons() {
  1048. const Edit = 'FeedTable'
  1049. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  1050. this.isRoleEdit = isRoleEdit
  1051. },
  1052. getInforvalueList() {
  1053. GetDataByName(this.requestParams2).then(response => {
  1054. if (response.data !== null) {
  1055. if (response.data.list[0].inforvalue == 0) {
  1056. this.isInforvalue = false
  1057. } else {
  1058. this.isInforvalue = true
  1059. }
  1060. } else {
  1061. this.isInforvalue = false
  1062. }
  1063. })
  1064. },
  1065. getDownList() {
  1066. GetDataByNames(this.requestParams).then(response => {
  1067. this.jumpDelayList = response.data.getDictByName.list
  1068. this.feedTypeList = response.data.getFeedclassByBig.list
  1069. this.planTypeList = response.data.getDictByName2.list
  1070. this.smallMaterialList = response.data.getTMRListEnableTypeFeed.list
  1071. })
  1072. },
  1073. getList() {
  1074. this.table.listLoading = true
  1075. GetDataByName(this.table.getdataListParm).then(response => {
  1076. console.log('table数据', response.data.list)
  1077. if (response.data.list !== null) {
  1078. this.table.list = response.data.list
  1079. this.table.pageNum = response.data.pageNum
  1080. this.table.pageSize = response.data.pageSize
  1081. this.table.total = response.data.total
  1082. } else {
  1083. this.table.list = []
  1084. }
  1085. setTimeout(() => {
  1086. this.table.listLoading = false
  1087. }, 100)
  1088. })
  1089. },
  1090. handleSearch() {
  1091. console.log('点击了查询')
  1092. this.table.getdataListParm.offset = 1
  1093. this.getList()
  1094. this.arrowDown = true
  1095. this.arrowUp = false
  1096. },
  1097. handleRefresh() {
  1098. console.log('点击了重置')
  1099. this.table.getdataListParm.parammaps.fname = ''
  1100. this.table.getdataListParm.parammaps.fclassid = ''
  1101. this.table.getdataListParm.parammaps.source = ''
  1102. this.table.getdataListParm.parammaps.autozone = ''
  1103. this.table.getdataListParm.parammaps.autosecond = ''
  1104. this.table.getdataListParm.parammaps.allowratio = ''
  1105. this.table.getdataListParm.parammaps.printgroup = ''
  1106. this.table.getdataListParm.parammaps.enable = ''
  1107. this.table.getdataListParm.offset = 1
  1108. this.getList()
  1109. },
  1110. resetTemp() {
  1111. this.create.temp = { pastureid: Cookies.get('pastureid'), fname: '', fclassid: '', fclass: '', feedcode: '', source: '用户自定义', printgroupid: '1', printgroup: '无', unitweight: '', uprice: '', allowratio: '', autozone: '', autosecond: '0', autosecondname: '禁用', confirmstart: '0', confirmstartname: '禁用', enable: '1', trgaddress: '', backup1: '', backup2: '', backup3: '', jmp: '0' }
  1112. },
  1113. // 计划类型
  1114. changePlanList(item) {
  1115. console.log(item, '======')
  1116. this.create.temp.printgroup = this.planTypeList.find(obj => obj.value === item).label
  1117. },
  1118. // 饲料类型
  1119. changeFeedList(item) {
  1120. this.create.temp.fclass = this.feedTypeList.find(obj => obj.id === item).mixname
  1121. },
  1122. // 跳转延时
  1123. changeAutosecond(item) {
  1124. this.create.temp.autosecondname = this.jumpDelayList.find(obj => obj.value === item).label
  1125. },
  1126. // 确认开始
  1127. changeConfirmstart(item) {
  1128. this.create.temp.confirmstartname = this.confirmStartList.find(obj => obj.id === item).name
  1129. },
  1130. changeSmallMaterial(item) {
  1131. if (item !== '') {
  1132. this.create.temp.smtmrname = this.smallMaterialList.find(obj => obj.id === item).tname
  1133. } else {
  1134. this.create.temp.smtmrname = ''
  1135. }
  1136. },
  1137. // 新增
  1138. handleCreate() {
  1139. console.log('点击了新增')
  1140. this.resetTemp()
  1141. this.dialogFull = false
  1142. this.create.dialogStatus = 'create'
  1143. this.create.dialogFormVisible = true
  1144. },
  1145. createData() {
  1146. console.log('点击了新增保存')
  1147. this.isokDisable = true
  1148. setTimeout(() => {
  1149. this.isokDisable = false
  1150. }, 1000)
  1151. this.$refs['temp'].validate(valid => {
  1152. if (valid) {
  1153. const unitweight = /^[1-9]\d*$/
  1154. if (this.create.temp.unitweight !== '') {
  1155. if (!unitweight.test(parseFloat(this.create.temp.unitweight))) {
  1156. this.$message({ type: 'error', message: '包装单位重量请输入正整数', duration: 2000 })
  1157. return false
  1158. }
  1159. }
  1160. // const uprice = /^\d+(\.\d{1,2})?$/
  1161. const uprice = /^(\d+|\d+\.\d{1,2})$/
  1162. if (this.create.temp.uprice !== '') {
  1163. if (!uprice.test(parseFloat(this.create.temp.uprice))) {
  1164. this.$message({ type: 'error', message: '单价请保留两位小数', duration: 2000 })
  1165. return false
  1166. }
  1167. }
  1168. if (this.create.temp.autozone !== '') {
  1169. const autozone = /^([0-9]|(1[0-9]|2[0-9]|3[0-9]|4[0-9]|(50)))$/
  1170. if (!autozone.test(parseFloat(this.create.temp.autozone))) {
  1171. this.$message({ type: 'error', message: '跳转重量域请输入大于等于0小于等于50的整数', duration: 2000 })
  1172. return false
  1173. }
  1174. } else {
  1175. this.create.temp.autozone = '0'
  1176. }
  1177. if (this.create.temp.trgaddress.length > 8) {
  1178. this.$message({ type: 'error', message: '继电器位置请输入1-8位数字', duration: 2000 })
  1179. return false
  1180. }
  1181. const allowratio = /^[0-9]\d*$/
  1182. if (this.create.temp.allowratio !== '') {
  1183. if (!allowratio.test(parseFloat(this.create.temp.allowratio))) {
  1184. this.$message({ type: 'error', message: '允许误差数请输入大于等于0的整数', duration: 2000 })
  1185. return false
  1186. }
  1187. }
  1188. this.isokDisable = true
  1189. setTimeout(() => {
  1190. this.isokDisable = false
  1191. }, 1000)
  1192. this.requestParam.name = 'insertFeed'
  1193. this.requestParam.parammaps = this.create.temp
  1194. if (this.create.temp.allowratio == '') { this.create.temp.allowratio = '0' }
  1195. if (this.create.temp.uprice == '') { this.create.temp.uprice = '0' }
  1196. if (this.create.temp.unitweight == '') { this.create.temp.unitweight = '0' }
  1197. if (this.create.temp.autozone == '') { this.create.temp.autozone = '0' }
  1198. if (this.create.temp.trgaddress == '') { this.create.temp.trgaddress = '0' }
  1199. PostDataByName(this.requestParam).then(response => {
  1200. console.log('新增保存发送参数', this.requestParam)
  1201. if (response.msg !== 'fail') {
  1202. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1203. this.create.dialogFormVisible = false
  1204. this.getList()
  1205. } else {
  1206. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1207. if (this.create.temp.allowratio == '0') { this.create.temp.allowratio = '' }
  1208. if (this.create.temp.uprice == '0') { this.create.temp.uprice = '' }
  1209. if (this.create.temp.unitweight == '0') { this.create.temp.unitweight = '' }
  1210. if (this.create.temp.autozone == '0') { this.create.temp.autozone = '' }
  1211. if (this.create.temp.trgaddress == '0') { this.create.temp.trgaddress = '' }
  1212. }
  1213. })
  1214. }
  1215. })
  1216. },
  1217. // 编辑
  1218. handleUpdate(row) {
  1219. console.log('点击了编辑', row)
  1220. this.create.dialogStatus = 'update'
  1221. this.dialogFull = false
  1222. this.create.dialogFormVisible = true
  1223. row.fclassid = String(row.fclassid)
  1224. row.printgroupid = String(row.printgroupid)
  1225. row.autosecond = String(row.autosecond)
  1226. row.confirmstart = String(row.confirmstart)
  1227. row.enable = String(row.enable)
  1228. row.jmp = String(row.jmp)
  1229. if (row.printgroupid !== '') {
  1230. row.printgroup = this.planTypeList.find(obj => obj.value == row.printgroupid).label
  1231. }
  1232. this.create.temp = Object.assign({}, row)
  1233. if (this.create.temp.allowratio == '0') { this.create.temp.allowratio = '' }
  1234. if (this.create.temp.uprice == '0.00') { this.create.temp.uprice = '' }
  1235. if (this.create.temp.unitweight == '0') { this.create.temp.unitweight = '' }
  1236. if (this.create.temp.autozone == '0') { this.create.temp.autozone = '' }
  1237. if (this.create.temp.trgaddress == '0') { this.create.temp.trgaddress = '' }
  1238. if (this.create.temp.smtmrid == '-1') { this.create.temp.smtmrid = '' }
  1239. console.log(this.create.temp, '=====123')
  1240. },
  1241. updateData() {
  1242. console.log('点击了编辑保存')
  1243. this.isokDisable = true
  1244. setTimeout(() => {
  1245. this.isokDisable = false
  1246. }, 1000)
  1247. this.$refs['temp'].validate(valid => {
  1248. if (valid) {
  1249. const unitweight = /^[1-9]\d*$/
  1250. if (this.create.temp.unitweight !== '') {
  1251. if (!unitweight.test(parseFloat(this.create.temp.unitweight))) {
  1252. this.$message({ type: 'error', message: '包装单位重量请输入正整数', duration: 2000 })
  1253. return false
  1254. }
  1255. }
  1256. // const uprice = /^\d+(\.\d{1,2})?$/
  1257. const uprice = /^(\d+|\d+\.\d{1,2})$/
  1258. if (this.create.temp.uprice !== '') {
  1259. if (!uprice.test(parseFloat(this.create.temp.uprice))) {
  1260. this.$message({ type: 'error', message: '单价请保留两位小数', duration: 2000 })
  1261. return false
  1262. }
  1263. }
  1264. if (this.create.temp.autozone !== '') {
  1265. const autozone = /^([0-9]|(1[0-9]|2[0-9]|3[0-9]|4[0-9]|(50)))$/
  1266. if (!autozone.test(parseFloat(this.create.temp.autozone))) {
  1267. this.$message({ type: 'error', message: '跳转重量域请输入大于等于0小于等于50的整数', duration: 2000 })
  1268. return false
  1269. }
  1270. } else {
  1271. this.create.temp.autozone = '0'
  1272. }
  1273. if (this.create.temp.trgaddress.length > 8) {
  1274. this.$message({ type: 'error', message: '继电器位置请输入1-8位数字', duration: 2000 })
  1275. return false
  1276. }
  1277. const allowratio = /^[0-9]\d*$/
  1278. if (this.create.temp.allowratio !== '') {
  1279. if (!allowratio.test(parseFloat(this.create.temp.allowratio))) {
  1280. this.$message({ type: 'error', message: '允许误差数请输入大于等于0的整数', duration: 2000 })
  1281. return false
  1282. }
  1283. }
  1284. this.isokDisable = true
  1285. setTimeout(() => {
  1286. this.isokDisable = false
  1287. }, 1000)
  1288. this.requestParam.name = 'updateFeed'
  1289. this.requestParam.parammaps = this.create.temp
  1290. if (this.create.temp.allowratio == '') { this.create.temp.allowratio = '0' }
  1291. if (this.create.temp.uprice == '') { this.create.temp.uprice = '0' }
  1292. if (this.create.temp.unitweight == '') { this.create.temp.unitweight = '0' }
  1293. if (this.create.temp.autozone == '') { this.create.temp.autozone = '0' }
  1294. if (this.create.temp.trgaddress == '') { this.create.temp.trgaddress = '0' }
  1295. PostDataByName(this.requestParam).then(response => {
  1296. console.log('新增保存发送参数', this.requestParam)
  1297. if (response.msg !== 'fail') {
  1298. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1299. this.create.dialogFormVisible = false
  1300. this.getList()
  1301. } else {
  1302. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1303. if (this.create.temp.allowratio == '0') { this.create.temp.allowratio = '' }
  1304. if (this.create.temp.uprice == '0') { this.create.temp.uprice = '' }
  1305. if (this.create.temp.unitweight == '0') { this.create.temp.unitweight = '' }
  1306. if (this.create.temp.autozone == '0') { this.create.temp.autozone = '' }
  1307. if (this.create.temp.trgaddress == '0') { this.create.temp.trgaddress = '' }
  1308. }
  1309. })
  1310. }
  1311. })
  1312. },
  1313. // 饲料库
  1314. handleFeedBank() {
  1315. console.log('点击了饲料库')
  1316. this.dialogFull = false
  1317. this.feedBank.dialogStatus = 'feedBank'
  1318. this.feedBank.dialogFormVisible = true
  1319. this.getFeedBankList()
  1320. },
  1321. getFeedBankList() {
  1322. this.feedBank.listLoading = true
  1323. GetDataByName(this.feedBank.getdataListParm).then(response => {
  1324. console.log('table数据', response.data.list)
  1325. if (response.data.list !== null) {
  1326. this.feedBank.list = response.data.list
  1327. this.feedBank.pageNum = response.data.pageNum
  1328. this.feedBank.pageSize = response.data.pageSize
  1329. this.feedBank.total = response.data.total
  1330. } else {
  1331. this.feedBank.list = []
  1332. }
  1333. setTimeout(() => {
  1334. this.feedBank.listLoading = false
  1335. }, 100)
  1336. })
  1337. },
  1338. handleFeedBankSearch() {
  1339. console.log('点击了饲料库搜索')
  1340. this.getFeedBankList()
  1341. this.feedBank.getdataListParm.offset = 1
  1342. },
  1343. handleFeedBankRefresh() {
  1344. console.log('点击了饲料库重置')
  1345. this.feedBank.getdataListParm.parammaps.fname = ''
  1346. this.feedBank.getdataListParm.parammaps.statue = ''
  1347. this.getFeedBankList()
  1348. },
  1349. // 关联
  1350. handleRelation(row) {
  1351. console.log('点击了关联')
  1352. this.dialogFull = false
  1353. this.relation.dialogStatus = 'relation'
  1354. this.relation.dialogFormVisible = true
  1355. this.relation.temp = Object.assign({}, row)
  1356. this.relation.getdataListParm.parammaps.fid = this.relation.temp.id
  1357. this.getRelationList()
  1358. },
  1359. getRelationList() {
  1360. this.relation.listLoading = true
  1361. GetDataByName(this.relation.getdataListParm).then(response => {
  1362. console.log('table数据', response.data.list)
  1363. if (response.data.list !== null) {
  1364. this.relation.list = response.data.list
  1365. this.relation.pageNum = response.data.pageNum
  1366. this.relation.pageSize = response.data.pageSize
  1367. this.relation.total = response.data.total
  1368. } else {
  1369. this.relation.list = []
  1370. }
  1371. setTimeout(() => {
  1372. this.relation.listLoading = false
  1373. }, 100)
  1374. })
  1375. },
  1376. handleRelationSearch() {
  1377. console.log('点击了关联搜索')
  1378. this.relation.getdataListParm.offset = 1
  1379. this.getRelationList()
  1380. },
  1381. disassociateData(row) {
  1382. console.log('点击了取消关联')
  1383. MessageBox.confirm('是否确认取消关联?', {
  1384. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1385. }).then(() => {
  1386. this.isokDisable = true
  1387. setTimeout(() => {
  1388. this.isokDisable = false
  1389. }, 1000)
  1390. this.requestParam.name = 'updateFeedrelation'
  1391. this.requestParam.parammaps = {}
  1392. this.requestParam.parammaps.pastureid = this.relation.temp.pastureid
  1393. this.requestParam.parammaps.fid = this.relation.temp.id
  1394. this.requestParam.parammaps.id = row.id
  1395. PostDataByName(this.requestParam).then(response => {
  1396. console.log('取消关联保存发送参数', this.requestParam)
  1397. if (response.msg !== 'fail') {
  1398. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1399. this.getRelationList()
  1400. this.getList()
  1401. } else {
  1402. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1403. }
  1404. })
  1405. }).catch(() => {
  1406. this.$message({ type: 'info', message: '已取消' })
  1407. })
  1408. },
  1409. relationData(row) {
  1410. console.log('点击了关联保存')
  1411. MessageBox.confirm('是否确认关联?', {
  1412. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1413. }).then(() => {
  1414. this.isokDisable = true
  1415. setTimeout(() => {
  1416. this.isokDisable = false
  1417. }, 1000)
  1418. this.requestParam.name = 'insertFeednur'
  1419. this.requestParam.parammaps = {}
  1420. this.requestParam.parammaps.pastureid = this.relation.temp.pastureid
  1421. this.requestParam.parammaps.fid = this.relation.temp.id
  1422. this.requestParam.parammaps.fname = this.relation.temp.fname
  1423. this.requestParam.parammaps.feedcode = this.relation.temp.feedcode
  1424. this.requestParam.parammaps.price = row.price
  1425. this.requestParam.parammaps.remark = row.remark
  1426. this.requestParam.parammaps.dry = row.dry
  1427. this.requestParam.parammaps.starch = row.starch
  1428. this.requestParam.parammaps.cp = row.cp
  1429. this.requestParam.parammaps.ca = row.ca
  1430. this.requestParam.parammaps.p = row.p
  1431. this.requestParam.parammaps.n = row.n
  1432. this.requestParam.parammaps.fat = row.fat
  1433. this.requestParam.parammaps.adf = row.adf
  1434. this.requestParam.parammaps.ndf = row.ndf
  1435. this.requestParam.parammaps.ndip = row.ndip
  1436. this.requestParam.parammaps.ash = row.ash
  1437. this.requestParam.parammaps.fpercent = row.fpercent
  1438. this.requestParam.parammaps.iscu = row.iscu
  1439. this.requestParam.parammaps.feednurid = row.id
  1440. PostDataByName(this.requestParam).then(response => {
  1441. console.log('关联保存发送参数', this.requestParam)
  1442. if (response.msg !== 'fail') {
  1443. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1444. this.getRelationList()
  1445. this.getList()
  1446. } else {
  1447. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1448. }
  1449. })
  1450. }).catch(() => {
  1451. this.$message({ type: 'info', message: '已取消' })
  1452. })
  1453. },
  1454. // 营养价值
  1455. handleNutritive(row) {
  1456. console.log('点击了营养价值', row)
  1457. this.dialogFull = false
  1458. this.nutritive.dialogStatus = 'nutritive'
  1459. this.nutritive.dialogFormVisible = true
  1460. this.nutritive.temp = Object.assign({}, row)
  1461. },
  1462. nutritiveData() {
  1463. console.log('点击了营养价值保存')
  1464. this.isokDisable = true
  1465. setTimeout(() => {
  1466. this.isokDisable = false
  1467. }, 1000)
  1468. if (this.nutritive.temp.dry == undefined) { this.$set(this.nutritive.temp, 'dry', '') }
  1469. if (this.nutritive.temp.starch == undefined) { this.$set(this.nutritive.temp, 'starch', '') }
  1470. if (this.nutritive.temp.cp == undefined) { this.$set(this.nutritive.temp, 'cp', '') }
  1471. if (this.nutritive.temp.ca == undefined) { this.$set(this.nutritive.temp, 'ca', '') }
  1472. if (this.nutritive.temp.p == undefined) { this.$set(this.nutritive.temp, 'p', '') }
  1473. if (this.nutritive.temp.n == undefined) { this.$set(this.nutritive.temp, 'n', '') }
  1474. if (this.nutritive.temp.fat == undefined) { this.$set(this.nutritive.temp, 'fat', '') }
  1475. if (this.nutritive.temp.adf == undefined) { this.$set(this.nutritive.temp, 'adf', '') }
  1476. if (this.nutritive.temp.ndf == undefined) { this.$set(this.nutritive.temp, 'ndf', '') }
  1477. if (this.nutritive.temp.ndip == undefined) { this.$set(this.nutritive.temp, 'ndip', '') }
  1478. if (this.nutritive.temp.ash == undefined) { this.$set(this.nutritive.temp, 'ash', '') }
  1479. var positiveNumber = /^\d+(\.\d{1,2})?$/
  1480. if (this.nutritive.temp.dry !== '') {
  1481. if (!positiveNumber.test(parseFloat(this.nutritive.temp.dry))) {
  1482. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1483. return false
  1484. }
  1485. }
  1486. console.log(this.nutritive.temp.starch)
  1487. if (this.nutritive.temp.starch !== '') {
  1488. if (!positiveNumber.test(parseFloat(this.nutritive.temp.starch))) {
  1489. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1490. return false
  1491. }
  1492. }
  1493. if (this.nutritive.temp.cp !== '') {
  1494. if (!positiveNumber.test(parseFloat(this.nutritive.temp.cp))) {
  1495. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1496. return false
  1497. }
  1498. }
  1499. if (this.nutritive.temp.ca !== '') {
  1500. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ca))) {
  1501. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1502. return false
  1503. }
  1504. }
  1505. if (this.nutritive.temp.p !== '') {
  1506. if (!positiveNumber.test(parseFloat(this.nutritive.temp.p))) {
  1507. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1508. return false
  1509. }
  1510. }
  1511. if (this.nutritive.temp.n !== '') {
  1512. if (!positiveNumber.test(parseFloat(this.nutritive.temp.n))) {
  1513. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1514. return false
  1515. }
  1516. }
  1517. if (this.nutritive.temp.fat !== '') {
  1518. if (!positiveNumber.test(parseFloat(this.nutritive.temp.fat))) {
  1519. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1520. return false
  1521. }
  1522. }
  1523. if (this.nutritive.temp.adf !== '') {
  1524. if (!positiveNumber.test(parseFloat(this.nutritive.temp.adf))) {
  1525. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1526. return false
  1527. }
  1528. }
  1529. if (this.nutritive.temp.ndf !== '') {
  1530. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ndf))) {
  1531. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1532. return false
  1533. }
  1534. }
  1535. if (this.nutritive.temp.ndip !== '') {
  1536. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ndip))) {
  1537. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1538. return false
  1539. }
  1540. }
  1541. if (this.nutritive.temp.ash !== '') {
  1542. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ash))) {
  1543. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1544. return false
  1545. }
  1546. }
  1547. this.requestParam.name = 'insertFeednur'
  1548. this.requestParam.parammaps = {}
  1549. this.requestParam.parammaps.pastureid = this.nutritive.temp.pastureid
  1550. this.requestParam.parammaps.fid = this.nutritive.temp.id
  1551. this.requestParam.parammaps.fname = this.nutritive.temp.fname
  1552. this.requestParam.parammaps.feedcode = this.nutritive.temp.feedcode
  1553. this.requestParam.parammaps.price = this.nutritive.temp.uprice
  1554. this.requestParam.parammaps.remark = this.nutritive.temp.remark
  1555. this.requestParam.parammaps.dry = this.nutritive.temp.dry
  1556. this.requestParam.parammaps.starch = this.nutritive.temp.starch
  1557. this.requestParam.parammaps.cp = this.nutritive.temp.cp
  1558. this.requestParam.parammaps.ca = this.nutritive.temp.ca
  1559. this.requestParam.parammaps.p = this.nutritive.temp.p
  1560. this.requestParam.parammaps.n = this.nutritive.temp.n
  1561. this.requestParam.parammaps.fat = this.nutritive.temp.fat
  1562. this.requestParam.parammaps.adf = this.nutritive.temp.adf
  1563. this.requestParam.parammaps.ndf = this.nutritive.temp.ndf
  1564. this.requestParam.parammaps.ndip = this.nutritive.temp.ndip
  1565. this.requestParam.parammaps.ash = this.nutritive.temp.ash
  1566. this.requestParam.parammaps.fpercent = this.nutritive.temp.fpercent
  1567. this.requestParam.parammaps.iscu = this.nutritive.temp.iscu
  1568. this.requestParam.parammaps.feednurid = '-1'
  1569. PostDataByName(this.requestParam).then(response => {
  1570. console.log('关联保存发送参数', this.requestParam)
  1571. if (response.msg !== 'fail') {
  1572. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1573. this.getList()
  1574. this.nutritive.dialogFormVisible = false
  1575. } else {
  1576. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1577. }
  1578. })
  1579. },
  1580. // 行内删除
  1581. handleRowDelete(row) {
  1582. console.log('点击了行内删除')
  1583. MessageBox.confirm('是否确认删除此信息?', {
  1584. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1585. }).then(() => {
  1586. this.selectList = []
  1587. this.requestParam = {}
  1588. this.requestParam.common = { 'returnmap': '0' }
  1589. this.requestParam.data = []
  1590. this.requestParam.data[0] = { 'name': 'checkDeleteFeed', 'type': 'v', 'parammaps': {
  1591. 'pastureid': row.pastureid,
  1592. 'id': row.id
  1593. }}
  1594. this.requestParam.data[1] = { 'name': 'deleteFeed', 'type': 'e', 'parammaps': {
  1595. 'pastureid': row.pastureid,
  1596. 'id': row.id
  1597. }}
  1598. ExecDataByConfig(this.requestParam).then(response => {
  1599. console.log('删除保存发送参数', this.requestParam)
  1600. if (response.msg === 'fail') {
  1601. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1602. } else {
  1603. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1604. this.getList()
  1605. }
  1606. })
  1607. }).catch(() => {
  1608. this.$message({ type: 'info', message: '已取消删除' })
  1609. })
  1610. },
  1611. handleSelectionChange(val) {
  1612. console.log('勾选数据', val)
  1613. this.selectList = val
  1614. },
  1615. // 多项删除
  1616. handleDelete() {
  1617. console.log('点击了删除')
  1618. if (this.selectList.length == 0) {
  1619. this.$message({ type: 'error', message: '请选择饲料表信息', duration: 2000 })
  1620. } else {
  1621. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  1622. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1623. }).then(() => {
  1624. this.requestParam = {}
  1625. this.requestParam.common = { 'returnmap': '0' }
  1626. this.requestParam.data = []
  1627. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1628. this.requestParam.data[0].children = []
  1629. this.requestParam.data[0].children[0] = { 'name': 'checkDeleteFeed', 'type': 'v', 'parammaps': {
  1630. id: '@insertSpotList.id',
  1631. pastureid: '@insertSpotList.pastureid'
  1632. }}
  1633. this.requestParam.data[0].children[1] = { 'name': 'deleteFeed', 'type': 'e', 'parammaps': {
  1634. id: '@insertSpotList.id',
  1635. pastureid: '@insertSpotList.pastureid'
  1636. }}
  1637. ExecDataByConfig(this.requestParam).then(response => {
  1638. console.log('删除保存发送参数', this.requestParam)
  1639. if (response.msg === 'fail') {
  1640. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1641. } else {
  1642. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1643. this.getList()
  1644. }
  1645. })
  1646. })
  1647. }
  1648. },
  1649. handleChangeOrder() {
  1650. this.isOrder = false
  1651. this.rowDrop()
  1652. },
  1653. saveChangeOrder() {
  1654. // 保存顺序
  1655. var sortArr = []
  1656. for (let i = 0; i < this.table.list.length; i++) {
  1657. var obj = {}
  1658. obj.sort = i + 1
  1659. obj.id = this.table.list[i].id
  1660. obj.pastureid = this.table.list[i].pastureid
  1661. sortArr.push(obj)
  1662. }
  1663. this.requestParam = {}
  1664. this.requestParam.common = { 'returnmap': '0' }
  1665. this.requestParam.data = []
  1666. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': sortArr }}
  1667. this.requestParam.data[0].children = []
  1668. this.requestParam.data[0].children[0] = { 'name': 'updateFeedSort', 'type': 'e', 'parammaps': {
  1669. id: '@insertSpotList.id',
  1670. pastureid: '@insertSpotList.pastureid',
  1671. sort: '@insertSpotList.sort'
  1672. }}
  1673. ExecDataByConfig(this.requestParam).then(response => {
  1674. console.log('顺序切换保存发送参数', this.requestParam)
  1675. if (response.msg === 'fail') {
  1676. this.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  1677. } else {
  1678. this.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  1679. this.getList()
  1680. this.isOrder = true
  1681. }
  1682. })
  1683. },
  1684. cancelChangeOrder() {
  1685. // 取消顺序
  1686. this.getList()
  1687. this.isOrder = true
  1688. },
  1689. // 行拖拽
  1690. rowDrop() {
  1691. console.log(document.querySelector('#table .el-table__body-wrapper tbody'))
  1692. const tbody = document.querySelector('#table .el-table__body-wrapper tbody')
  1693. const that = this
  1694. var sortable = Sortable.create(tbody, {
  1695. disabled: that.dropState,
  1696. onChoose({ newIndex, oldIndex }) {
  1697. if (that.dropState == true) {
  1698. sortable.destroy()
  1699. }
  1700. },
  1701. onEnd({ newIndex, oldIndex }) {
  1702. const currRow = that.table.list.splice(oldIndex, 1)[0]
  1703. that.table.list.splice(newIndex, 0, currRow)
  1704. console.log('索引', newIndex)
  1705. console.log('拖动数据', currRow)
  1706. console.log('上', that.table.list[newIndex - 1])
  1707. console.log('下', that.table.list[newIndex + 1])
  1708. }
  1709. })
  1710. },
  1711. }
  1712. }
  1713. </script>
  1714. <style lang="scss" scoped>
  1715. .search{margin-top:10px;}
  1716. .table{margin-top:10px;}
  1717. $width:350px;
  1718. $left:325px;
  1719. .selectInput{
  1720. position: relative;
  1721. display: inline-block;
  1722. .Input{width: $width;position: relative;}
  1723. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  1724. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  1725. .selectUl{
  1726. z-index: 111;width: $width;background: #fff;border: 1px solid #E4E7ED;box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);margin: -1px 0 0 0;padding: 6px 0; margin: 0;box-sizing: border-box;position: absolute;
  1727. li{
  1728. list-style: none;font-size: 14px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #606266; height: 50px; line-height: 50px; box-sizing: border-box; cursor: pointer;
  1729. a{float:left;width: 80px;}
  1730. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  1731. }
  1732. }
  1733. }
  1734. </style>