index.vue 81 KB

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